WebSocket

(c) 2013-2014 http://ircanywhere.com

Author: Ricki Hastings

IRCAnywhere server/websocket.js

class WebSocket.WebSocket(socket)

Wrapper for sock.js sockets.

Arguments:
  • socket (object) – A valid sock.js socket
Returns:

void

WebSocket.bindEvents()

Binds our sock.js events to _socket.

Returns:void
WebSocket.isValid(parsed)

Checks if an incoming message object is valid.

Arguments:
  • parsed (object) – An incoming message object to parse
Returns:

Whether the object is valid or not

WebSocket.onMessage(raw)

Handles an incoming message.

Arguments:
  • raw (string) – A raw line from a sock.js websocket
Returns:

void

WebSocket.onClose()

Handles closing the websocket connection.

Returns:void
WebSocket.send(event, data[, close])

Sends outgoing packets

Arguments:
  • event (string) – The event to send
  • data (object) – The data object to send, should be JSON
  • [close] (boolean) – Whether to close the connection after the data has been sent or not
Returns:

void

WebSocket.sendBurst(data)

Compiles a temporary GET route and sends it to a socket

Arguments:
  • data (object) – The data object to push into a route and send down the socket
Returns:

void