Basic Query on Sending of data from Websocket client to Server?

Dec 8, 2014 at 5:33 AM
Hi
thanks for the Websocket4net was very useful.
using WebSocket4Net;

WebSocket websocket = new WebSocket("ws://localhost:2012/");
websocket.Opened += new EventHandler(websocket_Opened);
websocket.Error += new EventHandler<ErrorEventArgs>(websocket_Error);
websocket.Closed += new EventHandler(websocket_Closed);
websocket.MessageReceived += new EventHandler(websocket_MessageReceived);
websocket.Open();

private void websocket_Opened(object sender, EventArgs e)
{
 websocket.Send("Hello World!");
}

Is it mandatory to send data on the Websocket_Opened event for first time? I am not able to send the data if I don't send in the Websocket_Opened event? Could some one throw light on simple query :)
Thanks
Coordinator
Dec 22, 2014 at 6:32 AM
It doesn't mean you need send anything int the connection open event handler.

You must wait the connection open., and then you can send any data. The Open method of websocket is async.