I’m writing a BepInEx Plugin for the game Content Warning, and my WebSocket Client (the game) can’t receive messages for some reason (from the server), and OnMessage
does not emit.
I can see on my server that messages are being received, but I cant send messages to the client.
OnOpen
works. What am I doing wrong?
Here’s my code, stripped of unnecessary details:
ws = new WebSocket(Plugin.URL.Value);
ws.OnMessage += (sender, evt) =>
{
UnityEngine.Debug.Log(evt.Data); // Nothing Happens
// Handles Data
};
ws.OnError += (sender, evt) =>
{
UnityEngine.Debug.LogError(evt.Message); // Nothing Happens, except if you forcibly close the connection
};
ws.OnOpen += (sender, evt) =>
{
// Send SteamID to Server
UnityEngine.Debug.Log(SteamUser.GetSteamID().m_SteamID.ToString());
ws.Send(SteamUser.GetSteamID().m_SteamID.ToString());
};
ws.Connect();
I’ve tried logging it, and moving the code out of the existing using function, but to no avail. I expected the WebSocket to emit OnMessage
. I don’t have any problems running a mockup client in JS though. This isn’t a problem with the server.