sta / websocket-sharp

A C# implementation of the WebSocket protocol client and server
http://sta.github.io/websocket-sharp
MIT License
5.73k stars 1.66k forks source link

onMessage never emits #752

Closed RedBigz closed 5 months ago

RedBigz commented 5 months ago

Hi, I'm writing a BepInEx Plugin for the game Content Warning, and my WebSocket Client can't receive messages for some reason. 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();