About to implement websocket. Possibly the most complicated part