code: function parseWebSocketEvent(event) {
        try {
          var params = JSON.parse(event.data);
  
          if (typeof params.data === 'string') {
            try {
              params.data = JSON.parse(params.data);
            } catch (e) {
              if (!(e instanceof SyntaxError)) {
                throw e;
              }
            }
          }
  
          return params;
        } catch (e) {
          self.emit('error', {type: 'MessageParseError', error: e, data: event.data});
        }
      }
docs: Parses an event from the WebSocket to get
  the JSON payload that we require
  
  @param {MessageEvent} event  The event from the WebSocket.onmessage handler.