new com_prsonas_Sdk()
Constructs a new SDK object
Methods
-
log(message, data, type)
-
Logging function: defaults to console; allows for override
Parameters:
Name Type Description messagestring The message to be logged
dataObject Optional data object to be logged
typestring The type of log to be recorded: debug, error, warn or log
-
validateEvent(eventName)
-
Checks to make sure the event name is valid
Parameters:
Name Type Description eventNamestring The name of the event being checked.
Returns:
The name of the matching event; empty string if not valid.
- Type
- string
-
subscribe(eventName, handler)
-
Adds the handler for the specified event
Parameters:
Name Type Description eventNamestring The name of the event being subscribed to.
handlerstring The handler that will handle the event.
-
unsubscribe(eventName, handler)
-
Removes the handler for the specified event.
Parameters:
Name Type Description eventNamestring The name of the event.
handlerstring The handler that will be removed.
-
broadcast(eventObj)
-
Broadcasts the event with the given parameters
Parameters:
Name Type Description eventObjobject The object that will be broadcast.
-
inbound(eventObj)
-
Inbound message handler
Parameters:
Name Type Description eventObjobject The object that will be handled.
-
onWebSocketConnected(data)
-
Fires when the websocket is connected to the avatar
Parameters:
Name Type Description dataObject The data being handled.
-
onWebSocketDisconnected(data)
-
Fires when the websocket is disconnected from the avatar
Parameters:
Name Type Description dataObject The data being handled.
-
<async> isOnLine(callback)
-
Returns true if the API server is accessible
Parameters:
Name Type Description callbackfunction The method called with the online status.
-
registerCallback(name)
-
Registers a callback
Parameters:
Name Type Description namestring The name of the event that will be raised with the callback data
-
registerHandler(name, handler)
-
Registers an internal event handler
Parameters:
Name Type Description namestring The name of the even that will be handled
handlerfunction The handler to register
-
envCheck()
-
Environment sanity check
-
initHandlers(eventTypes)
-
Sets the default handlers for a module
Parameters:
Name Type Description eventTypesObject Lookup of all the event types to be initialized.