WebSocket for client (game) side, code refactoring