Refactor websocket stuff so we can add video messaging.
Refactor websocket code