Implement main parsing logic for WebSocket messages.