NetGain icon indicating copy to clipboard operation
NetGain copied to clipboard

When can you send clients data?

Open vgrigoriu opened this issue 8 years ago • 1 comments

I thought you can send as soon as the client connects, so I tried this:

public class ClientHandler : WebSocketsMessageProcessor
{
    protected override void OnOpened(WebSocketConnection connection)
    {
        connection.Send(Context, "hello");
    }
}

But the client didn't receive anything. A workaround I found is to have the client initiate the conversation and send whatever I need to send from OnReceive.

Is there another way to be notified when I can use the connection to talk to the client?

If it makes any difference, I'm using Websocket4Net on the client:

webSocket = new WebSocket("ws://localhost:1234/");
webSocket.Opened += WebSocket_Opened;
webSocket.MessageReceived += WebSocket_MessageReceived;
webSocket.Closed += WebSocket_Closed;
webSocket.Error += WebSocket_Error;
webSocket.Open();

vgrigoriu avatar Apr 03 '16 13:04 vgrigoriu

I have the same problem as well.

DoraemonYu avatar Jan 06 '17 04:01 DoraemonYu