new WebsocketParser( wss )

Description

Parser class for Websocket Protocol mocks

Parameters
Name Type Description
wss any

Instance of WebSocket server

Methods


send( mockFile, ws, request, incomingMessage )

Description

Compiles and transforms the handlerbars in a given mockfile and according to the key, i.e.

  • broadcast
  • emit; or
  • self sends the message from message.mock If it's the first message to be sent after connection, mockfile would be connection.mock
Parameters
Name Type Description
mockFile string

mockFile for the current connection

ws WebSocket

current socket

request IncomingMessage

incoming request

incomingMessage any

incoming data


sendConnect( ws, request, clients, clientId, status, mockFile )

Description

Sends a list of current clients connected to the server, id of the new client, and status (joining or leaving)

Parameters
Name Type Description
ws WebSocket

current socket

request IncomingMessage

Incoming request

clients Array.<string>

List of existin clients

clientId string

new clientId

status string

joining or leaving

mockFile string

mockfile, i.e. connection.mock