Class: util

easyrtc_public_obj~pub. util

new util()

General utility functions are grouped in this util object. For convenience, this class has also been attached to the application, connection, session, and room classes.
Source:

Members

<static> ApplicationError

Custom Error Object for EasyRTC Application Errors.
Source:

<static> ApplicationWarning

Custom Error Object for EasyRTC Application Warnings.
Source:

Methods

<static> 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> 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> 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> 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> 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> 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> isValidIncomingMessage(type, msg, appObj, callback)

Checks an incoming EasyRTC message to determine if it is syntactically valid.
Parameters:
Name Type Argument 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(?Error, boolean, string) Callback with error, a boolean of whether message if valid, and a string indicating the error code if the message is invalid.
Source:

<static> 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> log(level, logText, logFields)

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 Argument 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> logDebug(logText, logFields)

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

<static> logError(logText, logFields)

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

<static> logInfo(logText, logFields)

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

<static> logWarning(logText, logFields)

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

<static> 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> 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> 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> 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> 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: