Use Websocket-sharp to create a C # version of the WebSocket service
Websocketbehavior is the core object, he contains the OnOpen, OnMessage, OnClose, OnError four methods, and a sessions object. Familiar with WebSocket know the top four methods are used to handle client links, send messages, link close, and errors. Sessions is used to manage some of the connected connections. For each connection, a new Iwebsocketsession object will be added to the id,sessions. The onclose is triggered when the page is closed or refreshed, and the corresponding Iwebsocketsession object is removed in the sessions.
Step 1:using websocketsharp.server;
Step 2: Write the processing class, inheriting the class Websocketserver
Step 3: Create a Websocketserver object
var WSSV = New Websocketserver (4649);
Wssv. Addwebsocketservice<echo> ("/echo");
Wssv. Addwebsocketservice<chat> ("/chat");
Step 4: Start WebSocket server
Wssv. Start ();
Step 5: Stop WebSocket Server
Wssv. Stop (Code,reason);
Using Websocket-sharp