Handle websocket messages with switch.