The WebSocket protocol is not to be missed when it comes to node. It is perfectly matched to node, with two reasons.
The 1.WebSocket client time-based programming model is similar to custom events in node.
{
Client socket = new Client("http://localhost:3000");
socket.Opened += clien_Opened;
socket.Message += clien_Message;
socket.SocketConnectionClosed += clien_SocketConnectionClosed;
socket.Error += clien_Error;
ien_opened ; + = clien_message ; + = clien_socketconnectionclosed ; + = Clien_error;
Socket. On ("Connection", (fn) = =
{
Console.WriteLine ("Connect enevt start");
Socket. Emit ("Messgae", Rejson);
});
Socket. Connect ();
}
void Clien_error (object sender, ErrorEventArgs e)
{
Console.WriteLine ("A Error Show" +e.message);
}
void Clien_socketconnectionclosed (object sender, EventArgs e)
{
Console.WriteLine ("Socket Connection succeed!");
}
void Clien_message (object sender, Messageeventargs e)
{
if (E! = null && e.message.event = = "Message")
{
}
}
void Clien_opened (object sender, EventArgs e)
{
Console.WriteLine ("Socket was open ...");
}
C#socketio4netclient Access Node JS