Hi all,
I have been having trouble subscribing to events specifically in WebGL.
The use case is simple, I want to subscribe to the OnCreateEvent of a table in the table called ChatMessage.
I have written the code for the desktop build while developing and everything works as expected.
Then I switched to Webgl and adjusted the same code using the WebGL version.
#if UNITY_WEBGL
public async void subscribe()
{
MoralisLiveQueryCallbacks<ChatMessage> chatCallbacks = new MoralisLiveQueryCallbacks<ChatMessage>();
MoralisQuery<ChatMessage> chatQuery = await MoralisInterface.GetClient().Query<ChatMessage>();
chatCallbacks.OnCreateEvent += incomingChat;
chatQuery.Subscribe<ChatMessage>(chatCallbacks);
}
#else
public void subscribe()
{
MoralisLiveQueryCallbacks<ChatMessage> chatCallbacks = new MoralisLiveQueryCallbacks<ChatMessage>();
MoralisQuery<ChatMessage> chatQuery = MoralisInterface.GetClient().Query<ChatMessage>();
chatCallbacks.OnCreateEvent += incomingChat;
chatQuery.Subscribe<ChatMessage>(chatCallbacks);
}
#endif
This function is called when the user has successfully connected their wallet.
Specifically in MainMenuScript.cs provided in the boilerplate.
if (user != null)
{
**subscribe called here**
}
I have found a post that seems to have the exact issue that I have
And it looks like this bug was recognized and solved here
I am afraid in my case it doesn’t work.
Although I have the latest version of the boilerplate project, I can’t subscribe to the queries on WebGL.
I don’t see any console messages, the events just don’t seem to be detected.
I would appreciate anyone who is able to help
Thank you Moralis Family