I'm having a problem using WebSocket4Net library.
I have the event websocket_opened and when this event is raised on open if I don't send any messages I have an Exception
System.Exception : You must send data by websocket after websocket is opened
After I send this message I can't send any other messages. I execute the send command but I have no exceptions and it isn't working and If I check the state the websocket is open
If I close the Socket on the opened event and open it again in the closed_event I can send another message without problems.
So, if I want to send multiple messages I have to disconnect after sending a message and reconnect again to send the next message.
private static void websocket_Opened(object sender, EventArgs e)
{
websocket.Send(msg);
websocket.Close();
}
private static void websocket_Closed(object sender, EventArgs e)
{
websocket.Open();
}
Is this normal? Can you help me with this please?
I had a similar questions when I first time used WebSocket4Net. A good thing about this library that it has a repository on github with many examples of use (tests). These tests was very helpful for me to understand how it should work.
UPDATE: I saw Fred's comment below and I think I really need to add an example. So here is it, I've used this api: