We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello @sta -
Thanks for the great library! I'm having trouble understanding how WebSocketBehaviors work for a WebSocketServer.
Is there a new instance of the WebSocketBehavior instantiated for every new connection made to the server?
I'm trying to use a WebSocketBehavior to manage all connected clients and I'm getting duplicated messaging.
The text was updated successfully, but these errors were encountered:
`protected override void OnStart(string[] args) { try { server = new WebSocketServer("IPPort");
server.AddWebSocketService<Web>("/Web"); //server.AddWebSocketService<Phone>("/Phone"); //server.AddWebSocketService<Tablet>("/Tablet"); //server.AddWebSocketService<Desktop>("/Desktop"); server.Start(); Logs.toFile("OnStartLog.txt", "Success"); } catch (Exception error) { Logs.toFile("OnStartLog.txt", " Exception: " + error.Message); }
}`
Sorry, something went wrong.
`class Web : WebSocketBehavior { public Web() {
} protected override void OnOpen() { Logs.toFile("ClientOpenLog.txt", "Id: " + ID); } protected override void OnMessage(MessageEventArgs e) { try { JObject data = JObject.Parse(e.Data); switch (data["query"].ToString()) { case "query1": // break; case "query2": // break; default: Logs.toFile("OnMessageLog.txt", " Undifined Query:" + data["query"]); break; } } catch (Exception exception) { Logs.toFile("MessageRecievedLog.txt", "Exception:" + exception.Message); } } protected override void OnError(ErrorEventArgs e) { Logs.toFile("SocketExceptionsLog.txt", "SocketException:" + e.Message); } protected override void OnClose(CloseEventArgs e) { Logs.toFile("ClientCloseLog.txt", "Id: " + ID + ", Code: " + e.Code + ", Reason:" + e.Reason + ", WasClean:" + e.WasClean); }
No branches or pull requests
Hello @sta -
Thanks for the great library! I'm having trouble understanding how WebSocketBehaviors work for a WebSocketServer.
Is there a new instance of the WebSocketBehavior instantiated for every new connection made to the server?
I'm trying to use a WebSocketBehavior to manage all connected clients and I'm getting duplicated messaging.
The text was updated successfully, but these errors were encountered: