c# - SuperWebSocket server can receive only one message -
I follow SuperWebSocket discussions to create a small web socket server with echo functionality, however, my server only receives a message Can receive and send it back, when I try to send it to another message, the connection closes. I use to test my server.
This is my code (I use WPF without MVVM here):
Public partial class MainWindow: window {Private WebSocketServer ws; Public Manvindo () {Initialization (); } Private Zero ConnectButton_Click (Object Sender, RoutedEventArgs e) {var r = new RootConfig (); Var s = new serverConfig (); S.Name = "Supervisse"; S.IP = "any"; S.Port = 8089; S.Mode = SocketMode.Tcp; Var f = new SocketServerFactory (); If (ws! = Null) {ws.Stop (); Ws = null; } Ws = new WebSocketServer (); Ws.Setup (r, s, f); Ws.NewMessageReceived + = ws_NewMessage received; Ws.Start (); } Private Zero ws_NewMessageReceived (WebSocket session session, string e) {session.Send ("Message:" + E); }}
I can send messages to the server without problems, but can not get more than one message without closing the connection. What is the cause of this problem and how can I fix it Am I
Try changing:
ws.NewMessageReceived + = ws_NewMessageReceived ; With
:
ws.NewMessageReceived + = New SuperWebSocket.SessionEventHandler & lt; SuperWebSocket.WebSocketSession, string & gt; (Ws_NewMessageReceived);
Comments
Post a Comment