Refactored WebSocketServer.cs