I tweak XSockets.Net Server now.
I read http://xsockets.net/docs/c-server-api#using_events
Using events
The server side API offer a few events to help you out.
OnOpen
Invoked when the client is connected and the handshake is completed.
//Hook up the event in the constructor.
public MyController()
{
this.OnOpen += MyController_OnOpen;
}
void MyController_OnOpen(object sender, OnClientConnectArgs e)
{
//The connection is open...
}
so, if I do the below in VisualStduio.net
class MyController : XSocketController
{
//Hook up the event in the constructor.
public MyController()
{
this.OnOpen += MyController_OnOpen;
}
void MyController_OnOpen(object sender, OnClientConnectArgs e)
{
//The connection is open...
}
}
MyController_OnOpen
and OnClientConnectArgs
is cautioned with red underline, which obviously means no good and not going to work.
I was an OK C# coder before, and now I do node.js.
I know what they try to do is
var myController = XSocketCotroller();
var myController_onOpen = function(obj,e)
{
// The connection is open...
};
myControler.onOpen = myController_onOpen;
simple enough, but I don't know how to do this in C#.
Could you instruct. Thanks!
Guessing that you are using XSockets 3.0.6 ? But I will write samples for both 3.0.6 and the new 4.0
There is really no idea sending a connected event from the onOpen since the server will send a event automatically...
The name of the controller you have "Server" confuses me, anyway see below.
Server side
3.0.6
4.0
Client side
3.0.6
4.0
So the big difference between 3.* and 4.* is that you can multiplex over several controllers on one socket.
4.0 will support RPC and that makes the binding to "connected" obsolete... We can just call the method directly from the server using "Invoke"
Guessing that you are writing some custom client in NodeJS, but you will still receive the OnOpen data without sending it yourself from the OnOpen event on the controller!
Regards Uffe
I had to do
OnClientConnectArgs e)
is not sufficient that occurs the error.