Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

When can you send clients data? #8

Open
vgrigoriu opened this issue Apr 3, 2016 · 1 comment
Open

When can you send clients data? #8

vgrigoriu opened this issue Apr 3, 2016 · 1 comment

Comments

@vgrigoriu
Copy link

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();
@DoraemonYu
Copy link

I have the same problem as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants