Class: com_prsonas_Sdk

com_prsonas_Sdk

Sdk Class


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
message string

The message to be logged

data Object

Optional data object to be logged

type string

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
eventName string

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
eventName string

The name of the event being subscribed to.

handler string

The handler that will handle the event.


unsubscribe(eventName, handler)

Removes the handler for the specified event.

Parameters:
Name Type Description
eventName string

The name of the event.

handler string

The handler that will be removed.


broadcast(eventObj)

Broadcasts the event with the given parameters

Parameters:
Name Type Description
eventObj object

The object that will be broadcast.


inbound(eventObj)

Inbound message handler

Parameters:
Name Type Description
eventObj object

The object that will be handled.


onWebSocketConnected(data)

Fires when the websocket is connected to the avatar

Parameters:
Name Type Description
data Object

The data being handled.


onWebSocketDisconnected(data)

Fires when the websocket is disconnected from the avatar

Parameters:
Name Type Description
data Object

The data being handled.


<async> isOnLine(callback)

Returns true if the API server is accessible

Parameters:
Name Type Description
callback function

The method called with the online status.


registerCallback(name)

Registers a callback

Parameters:
Name Type Description
name string

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
name string

The name of the even that will be handled

handler function

The handler to register


envCheck()

Environment sanity check


initHandlers(eventTypes)

Sets the default handlers for a module

Parameters:
Name Type Description
eventTypes Object

Lookup of all the event types to be initialized.