public override void OnWebSocketOpen(WebSocket webSocket) { User user = new User(webSocket, GenerateName()); webSocket.OnClose += (object sender, CloseArgs args) => { ConnectedUsers.RemoveAll(p => p.webSocket == webSocket); SendAll(user.Username + " disconnected"); }; webSocket.OnMessageReceived += MessageHandler; ConnectedUsers.Add(user); SendAll(user.Username + " connected!"); }
private void OnClientConnectionClose(object sender, ConnectionEventArgs cea) { ConnectedUsers.RemoveAll(uc => uc.Connection == (Connection)sender); Logger.Print("Server Object got ConnectionClosedEv fired, num of users=" + ConnectedUsers.Count); }