Added very basic WebSocket support to json server

This method has become very long, consider separating into private sub-methods.