Class: pub

easyrtc_public_obj~pub

new pub()

The public object which is returned by the EasyRTC listen() function. Contains all public methods for interacting with EasyRTC server.
Source:

Classes

events
util

Members

(static) events.defaultListeners

Map of EasyRTC event listener names to their default functions. This map can be used to run a default function manually.
Source:

(static) events.emit

Expose event listener's emit function.
Source:

(static) util.ApplicationError

Custom Error Object for EasyRTC Application Errors.
Source:

(static) util.ApplicationWarning

Custom Error Object for EasyRTC Application Warnings.
Source:

Methods

(static) app(appNamenullable, callbackopt)

Contains the methods for interfacing with an EasyRTC application. The callback will receive an application object upon successful retrieval of application. The callback may receive an Error object if unsuccessful. Depending on the severity, known errors have an "instanceof" ApplicationWarning or ApplicationError. The function does return an application object which is useful for chaining, however the callback approach is safer and provides additional information in the event of an error.
Parameters:
Name Type Attributes Description
appName string <nullable>
Application name which uniquely identifies it on the server. Uses default application if null.
callback appCallback <optional>
Callback with error and application object
Source:

(static) createApp(appName, optionsnullable, callbackopt)

Creates a new EasyRTC application with default values. If a callback is provided, it will receive the new application object. The callback may receive an Error object if unsuccessful. Depending on the severity, known errors have an "instanceof" ApplicationWarning or ApplicationError.
Parameters:
Name Type Attributes Description
appName string Application name which uniquely identifies it on the server.
options object <nullable>
Options object with options to apply to the application. May be null.
callback appCallback <optional>
Callback with error and application object
Source:

(static) events.emitDefault(eventName, …eventParam)

Runs the default EasyRTC listener for a given event.
Parameters:
Name Type Attributes Description
eventName string EasyRTC event name.
eventParam * <repeatable>
The event parameters
Source:

(static) events.on(eventName, listener)

Sets listener for a given EasyRTC event. Only one listener is allowed per event. Any other listeners for an event are removed before adding the new one. See the events documentation for expected listener parameters.
Parameters:
Name Type Description
eventName string Listener name.
listener function Function to be called when listener is fired
Source:

(static) events.removeAllListeners(eventNamenullable)

Removes all listeners for an event. If there is a default EasyRTC listener, it will be added. If eventName is `null`, all events will be removed than the defaults will be restored.
Parameters:
Name Type Attributes Description
eventName string <nullable>
Listener name. If `null`, then all events will be removed.
Source:

(static) events.setDefaultListener(eventName)

Resets the listener for a given event to the default listener. Removes other listeners.
Parameters:
Name Type Description
eventName string EasyRTC event name.
Source:

(static) events.setDefaultListeners()

Resets the listener for all EasyRTC events to the default listeners. Removes all other listeners.
Source:

(static) getAppNames(callback)

Sends an array of all application names to a callback.
Parameters:
Name Type Description
callback function Callback with error and array containing all application names.
Source:

(static) getAppWithEasyrtcid(easyrtcid, callback)

Gets app object for application which has an authenticated client with a given easyrtcid
Parameters:
Name Type Description
easyrtcid String Unique identifier for an EasyRTC connection.
callback function Callback with error and application object
Source:

(static) getConnectionCount(callback)

Sends the count of the number of connections to the server to a provided callback.
Parameters:
Name Type Description
callback function Callback with error and array containing all easyrtcids.
Source:

(static) getConnectionCountSync() → {Number}

Sends the count of the number of connections to the server to a provided callback.
Source:
Returns:
The current number of connections in a room.
Type
Number

(static) getConnectionWithEasyrtcid(easyrtcid, callback)

Gets connection object for connection which has an authenticated client with a given easyrtcid
Parameters:
Name Type Description
easyrtcid string EasyRTC unique identifier for a socket connection.
callback function Callback with error and connection object
Source:

(static) getOption(optionName) → {*}

Gets individual option value. The option value returned is for the server level. Note that some options can be set at the application or room level. If an option has not been set at the room level, it will check to see if it has been set at the application level, if not it will revert to the server level.
Parameters:
Name Type Description
optionName String Option name
Source:
Returns:
Option value (can be any JSON type)
Type
*

(static) getVersion() → {string}

Gets EasyRTC Version. The format is in a major.minor.patch format with an optional letter following denoting alpha or beta status. The version is retrieved from the package.json file located in the EasyRTC project root folder.
Source:
Returns:
EasyRTC Version
Type
string

(static) isApp(appName, callback)

Determine if a given application name has been defined.
Parameters:
Name Type Description
appName string Application name which uniquely identifies it on the server.
callback function Callback with error and boolean of whether application is defined.
Source:

(static) setOption(optionName, optionValue) → {Boolean}

Sets individual option. The option value set is for the server level. Note that some options can be set at the application or room level. If an option has not been set at the room level, it will check to see if it has been set at the application level, if not it will revert to the server level.
Parameters:
Name Type Description
optionName Object Option name
optionValue Object Option value
Source:
Returns:
true on success, false on failure
Type
Boolean

(static) util.ConnectionError(msg) → {Error}

Custom Error Object for EasyRTC C Errors.
Parameters:
Name Type Description
msg string Text message describing the error.
Source:
Returns:
Type
Error

(static) util.ConnectionWarning(msg) → {Error}

Custom Error Object for EasyRTC Connection Warnings.
Parameters:
Name Type Description
msg string Text message describing the error.
Source:
Returns:
Type
Error

(static) util.deepCopy(input) → {Object}

Performs a deep copy of an object, returning the duplicate. Do not use on objects with circular references.
Parameters:
Name Type Description
input Object Input variable (or object) to be copied.
Source:
Returns:
New copy of variable.
Type
Object

(static) util.getAvailableEasyrtcid() → {String}

Returns a random available easyrtcid.
Source:
Returns:
Available easyrtcid. A unique identifier for an EasyRTC connection.
Type
String

(static) util.getErrorMsg(errorCode) → {Object}

Returns an EasyRTC message error object for a specific error code. This is meant to be emitted or returned to a websocket client.
Parameters:
Name Type Description
errorCode String EasyRTC error code associated with an error.
Source:
Returns:
EasyRTC message error object for the specific error code.
Type
Object

(static) util.getErrorText(errorCode) → {string}

Returns human readable text for a given error code. If an unknown error code is provided, a null value will be returned.
Parameters:
Name Type Description
errorCode String EasyRTC error code associated with an error.
Source:
Returns:
Human readable error string
Type
string

(static) util.isError(Will) → {Boolean}

Determines if an Error object is an instance of ApplicationError, ConnectionError, or ServerError. If it is, it will return true.
Parameters:
Name Type Description
Will * | Error accept any value, but will only return true for appropriate error objects.
Source:
Returns:
Type
Boolean

(static) util.isValidIncomingMessage(type, msg, appObjnullable, callback)

Checks an incoming EasyRTC message to determine if it is syntactically valid.
Parameters:
Name Type Attributes Description
type string The Socket.IO message type. Expected values are (easyrtcAuth|easyrtcCmd|easyrtcMsg)
msg Object Message object which contains the full message from a client; this can include the standard msgType and msgData fields.
appObj Object <nullable>
EasyRTC application object. Contains methods used for identifying and managing an application.
callback function Callback with error, a boolean of whether message if valid, and a string indicating the error code if the message is invalid.
Source:

(static) util.isWarning(Will) → {Boolean}

Determines if an Error object is an instance of ApplicationWarning, ConnectionWarning, or ServerWarning. If it is, it will return true.
Parameters:
Name Type Description
Will * | Error accept any value, but will only return true for appropriate error objects.
Source:
Returns:
Type
Boolean

(static) util.log(level, logText, logFieldsopt, nullable)

General logging function which emits a log event so long as the log level has a severity equal or greater than e.option.logLevel
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.
Source:

(static) util.logDebug(logText, logFieldsopt, nullable)

Convenience function for logging "debug" level items.
Parameters:
Name Type Attributes Description
logText string Text for log.
logFields * <optional>
<nullable>
Simple JSON object which contains extra fields to be logged.
Source:

(static) util.logError(logText, logFieldsopt, nullable)

Convenience function for logging "error" level items.
Parameters:
Name Type Attributes Description
logText string Text for log.
logFields * <optional>
<nullable>
Simple JSON object which contains extra fields to be logged.
Source:

(static) util.logInfo(logText, logFieldsopt, nullable)

Convenience function for logging "info" level items.
Parameters:
Name Type Attributes Description
logText string Text for log.
logFields * <optional>
<nullable>
Simple JSON object which contains extra fields to be logged.
Source:

(static) util.logWarning(logText, logFieldsopt, nullable)

Convenience function for logging "warning" level items.
Parameters:
Name Type Attributes Description
logText string Text for log.
logFields * <optional>
<nullable>
Simple JSON object which contains extra fields to be logged.
Source:

(static) util.nextToNowhere(err)

An empty dummy function, which is designed to be used as a default callback in functions when none has been provided.
Parameters:
Name Type Description
err Error Error object
Source:

(static) util.sendSessionCookie(req, res)

Will attempt to deliver an EasyRTC session id via a cookie. Requires that session management be enabled from within Express.
Parameters:
Name Type Description
req Object Http request object
res Object Http result object
Source:

(static) util.sendSocketCallbackAck(easyrtcid, socketCallback, appObjnullable)

Sends an 'ack' socket message to a given socketCallback. Provides additional checking and logging.
Parameters:
Name Type Attributes Description
easyrtcid string EasyRTC unique identifier for a socket connection.
socketCallback function Socket.io callback function
appObj Object <nullable>
EasyRTC application object. Contains methods used for identifying and managing an application.
Source:

(static) util.sendSocketCallbackMsg(easyrtcid, socketCallback, msg, appObjnullable)

Sends a complete socket message to a given socketCallback. Provides additional checking and logging.
Parameters:
Name Type Attributes Description
easyrtcid string EasyRTC unique identifier for a socket connection.
socketCallback function Socket.io callback function
msg Object Message object which contains the full message for a client; this can include the standard msgType and msgData fields.
appObj Object <nullable>
EasyRTC application object. Contains methods used for identifying and managing an application.
Source:

(static) util.ServerError(msg) → {Error}

Custom Error Object for EasyRTC Server Errors.
Parameters:
Name Type Description
msg string Text message describing the error.
Source:
Returns:
Type
Error

(static) util.ServerWarning(msg) → {Error}

Custom Error Object for EasyRTC Server Warnings.
Parameters:
Name Type Description
msg string Text message describing the error.
Source:
Returns:
Type
Error

(static) util.updateCheck()

Checks with EasyRTC site for latest version. Writes to the log if a version can be found. If connection cannot be established than no error will be shown.
Source: