Class: eventListener

easyrtc_default_event_listeners~eventListener

new eventListener()

Event listeners used by EasyRTC. Many of these can be overridden using server options. The interfaces should be used as a guide for creating new listeners.
Source:

Methods

(static) onAuthenticate(socket, easyrtcid, appName, usernamenullable, credentialnullable, easyrtcAuthMessage, next)

Default listener for event "authenticate". This event is called as part of the authentication process. To deny authentication, call the next() with an Error. By default everyone gets in!
Parameters:
Name Type Attributes Description
socket Object Socket.io socket object. References the individual connection socket.
easyrtcid String Unique identifier for an EasyRTC connection.
appName string Application name which uniquely identifies it on the server.
username String <nullable>
Username to assign to the connection.
credential * <nullable>
Credential for the connection. Can be any JSONable object.
easyrtcAuthMessage Object Message object containing the complete authentication message sent by the connection.
next nextCallback A success callback of form next(err).
Source:

(static) onAuthenticated(connectionObj, next)

Default listener for event "authenticated". This event is called after a connection is authenticated and the connection object is generated and requested rooms are joined. Call next(err) to continue the connection procedure.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
next nextCallback A success callback of form next(err).
Source:

(static) onConnection(socket, easyrtcid, next)

Default listener for event "connection". This event is called when socket.io accepts a new connection.
Parameters:
Name Type Description
socket Object Socket.io socket object. References the individual connection socket.
easyrtcid String Unique identifier for an EasyRTC connection.
next nextCallback A success callback of form next(err).
Source:

(static) onDisconnect(connectionObj, next)

Default listener for event "disconnect". This event is called when socket.io detects a disconnection. Disconnections can occur due to either side purposefully dropping a connection, network disconnection, or time out.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
next nextCallback A success callback of form next(err).
Source:

(static) onEasyrtcAuth(socket, easyrtcid, msg, socketCallback, callback)

Default listener for event "easyrtcAuth". This event is fired when an incoming 'easyrtcAuth' message is received from a client.
Parameters:
Name Type Description
socket Object Socket.io socket object. References the individual connection socket.
easyrtcid String Unique identifier for an EasyRTC connection.
msg Object Message object which contains the full message from a client; this can include the standard msgType and msgData fields.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
callback function Callback to call upon completion. Delivers parameter (err, connectionObj).
Source:

(static) onEasyrtcCmd(connectionObj, msg, socketCallback, next)

Default listener for event "easyrtcCmd". This event is fired when an incoming 'easyrtcCmd' message is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
msg Object Message object which contains the full message from a client; this can include the standard msgType and msgData fields.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onEasyrtcMsg(connectionObj, msg, socketCallback, next)

Default listener for event "easyrtcMsg". This event is fired when an incoming 'easyrtcMsg' message is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
msg Object Message object which contains the full message from a client; this can include the standard msgType and msgData fields.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onEmitEasyrtcCmd(connectionObj, msgType, msg, socketCallback, next)

Default listener for event "emitEasyrtcCmd". This event is fired when the server should emit an EasyRTC command to a client. The easyrtcid and serverTime fields will be added to the msg automatically.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
msgType String Message type of the message.
msg Object Message object which contains the full message to a client; this can include the standard msgData field.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onEmitEasyrtcMsg(connectionObj, msgType, msg, socketCallback, next)

Default listener for event "emitEasyrtcMsg". This event is fired when the server should emit an EasyRTC message to a client. The easyrtcid and serverTime fields will be added to the msg automatically.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
msgType String Message type of the message.
msg Object Message object which contains the full message to a client; this can include the standard msgData field.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onEmitError(connectionObj, errorCode, socketCallback, next)

Default listener for event "emitError". This event is fired when the server should emit an EasyRTC error to a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
errorCode String EasyRTC error code associated with an error.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onEmitReturnAck(connectionObj, socketCallback, next)

Default listener for event "emitReturnAck". This event is fired when the server should return an Ack to a client via an acknowledgment message.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onEmitReturnError(connectionObj, socketCallback, errorCode, next)

Default listener for event "emitReturnError". This event is fired when the server should return an Error to a client via an acknowledgment message.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
errorCode String EasyRTC error code associated with an error.
next nextCallback A success callback of form next(err).
Source:

(static) onEmitReturnToken(connectionObj, socketCallback, next)

Default listener for event "emitReturnToken". This event is fired when the server should return a token to a client via an acknowledgment message. This is done after a client has been authenticated and the connection has been established.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onGetIceConfig(connectionObj, callback)

Default listener for event "getIceConfig". Returns an ICE configuration object to the callback. The ICE configuration object will hold the array of STUN and TURN servers the connection should use when forming a peer connection. This default listener uses the "appIceServers" configuration option at the application level.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
callback function Callback of form (err, iceConfigArray)
Source:

(static) onLog(level, logText, logFieldsopt, nullable, nextnullable)

Default listener for event "log". This event is fired when ever a loggable item is observed.
Parameters:
Name Type Attributes Description
level string Log severity level. Can be ("debug"|"info"|"warning"|"error")
logText string Text for log.
logFields * <optional>
<nullable>
Simple JSON object which contains extra fields to be logged.
next nextCallback <nullable>
A success callback of form next(err).
Source:

(static) onMsgTypeGetIceConfig(connectionObj, socketCallback, next)

Default listener for event "msgTypeGetIceConfig". This event is fired when an easyrtcCmd message with msgType of "getIceConfig" is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onMsgTypeGetRoomList(connectionObj, socketCallback, next)

Default listener for event "msgTypeGetRoomList". This event is fired when an easyrtcCmd message with msgType of "getRoomList" is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onMsgTypeRoomJoin(connectionObj, rooms, socketCallback, next)

Default listener for event "msgTypeRoomJoin". This event is fired when an easyrtcCmd message with msgType of "roomJoin" is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
rooms Object A room object containing a map of room names and room parameters.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onMsgTypeRoomLeave(connectionObj, rooms, socketCallback, next)

Default listener for event "msgTypeRoomLeave". This event is fired when an easyrtcCmd message with msgType of "roomLeave" is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
rooms Object A room object containing a map of room names.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onMsgTypeSetPresence(connectionObj, presenceObj, socketCallback, next)

Default listener for event "msgTypeSetPresence". This event is fired when an easyrtcCmd message with msgType of "setPresence" is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
presenceObj Object Presence object which contains all the fields for setting a presence for a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onMsgTypeSetRoomApiField(connectionObj, roomApiFieldObj, socketCallback, next)

Default listener for event "msgTypeSetRoomApiField". This event is fired when an easyrtcCmd message with msgType of "setRoomApiField" is received from a client.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
roomApiFieldObj Object Api Field object which contains all the fields for setting a presence for a connection.
socketCallback function Socket.io callback function which delivers a response to a socket. Expects a single parameter (msg).
next nextCallback A success callback of form next(err).
Source:

(static) onRoomCreate(appObj, creatorConnectionObjnullable, roomName, roomOptionsnullable, callback)

Default listener for event "roomCreate". Creates a room attached to an application with a specified room name. The optional creatorConnectionObj is provided to provide context; joining the room is done separately. If successful, the callback returns a roomObj.
Parameters:
Name Type Attributes Description
appObj Object EasyRTC application object. Contains methods used for identifying and managing an application.
creatorConnectionObj Object <nullable>
EasyRTC connection object belonging to the creator of the room. Contains methods used for identifying and managing a connection.
roomName string Room name which uniquely identifies a room within an EasyRTC application.
roomOptions Object <nullable>
Sets room level options. May be null or map of key/value pairs.
callback function Callback of form (err, roomObj)
Source:

(static) onRoomJoin(connectionObj, roomName, roomParameternullable, callback)

Default listener for event "roomJoin". Joins a connection to a a specified room. If successful, the callback will return a connectionRoomObj.
Parameters:
Name Type Attributes Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
roomName string Room name which uniquely identifies a room within an EasyRTC application.
roomParameter Object <nullable>
A map(dictionary) object with key/value pairs. The values can be any JSONable object. This field is not currently looked at by EasyRTC, however it is available for custom server applications. May be used for room options or authentication needs.
callback function Callback of form (err, connectionRoomObj)
Source:

(static) onRoomLeave(connectionObj, roomName, next)

Default listener for event "roomLeave". Run upon a connection leaving a room.
Parameters:
Name Type Description
connectionObj Object EasyRTC connection object. Contains methods used for identifying and managing a connection.
roomName string Room name which uniquely identifies a room within an EasyRTC application.
next nextCallback A success callback of form next(err).
Source:

(static) onShutdown(next)

Default listener for event "shutdown". This event is fired when the server is being shutdown.
Parameters:
Name Type Description
next nextCallback A success callback of form next(err).
Source:

(static) onStartup(next)

Default listener for event "startup". This event initializes EasyRTC server so it is ready for connections.
Parameters:
Name Type Description
next nextCallback A success callback of form next(err).
Source: