INDEX

setEventListeners(DOMString Array events, Function Array listeners, Context context, DOMString sessionId, Function callback)

With setEventListener method client connections can listen events from the core. Clients implement the event listeners as exposed RPC methods with specific names, e.g. "ApplicationInstalled" to listen application installation events.

Parameter Description
events An array of event listener RPC method name strings.
methods An array of event listener callbacks.
context The context of the methods listed in the methods array.
sessionId Log in session id returned by the adminLogIn method..
callback User defined callback function that is called after the event listeners are set.

After the listeners are set the callback function is called with two arguments: callback(err, data).

Argument Type Desription
err JSON Object An error_object or null if no error occured.
data Boolean The return value is always true.

The events array contains all the events client wants to listen. The corresponding listeners array must contain the same number of callback functions as there are event names. The event names and callbacks are matched by their index. The listeners must be in the context passed in the parameters. setEventListener exposes the events automatically and they must not be already exposed. An example snippet below explains the concept.

var core = new SpaceifyCore();
var events = ["SpaceletInstalled", "SpaceletRemoved"];
var methods = [spaceletInstalled, spaceletRemoved];

core.setEventListeners(events, methods, this, null, function(err, data)
  {});

function spaceletInstalled(result)
  {}

function spaceletRemoved(result)
  {}

Non-admin clients can not set event listeners for some of the events and the sessionId parameter is required for those events. The core sends the RPC event requests to clients as notifications. The parameters for the requests vary depending of the event.

Spaceify core currently emits these events.


  • "SpaceletInstalled"
  • "SpaceletRemoved"
  • "SpaceletStopped"
  • "ApplicationInstalled"
  • "ApplicationRemoved"
  • "ApplicationStopped"
  • "NativeApplicationInstalled"
  • "NativeApplicationRemoved"
  • "NativeApplicationStopped"

The events are emitted when spacelet, application or native application is installed, removed or stopped. The core sends to listeners a JSON result object containing the manifest object of the spacelet, application or native application.

{
manifest: object
}

  • "SpaceletStarted"
  • "ApplicationStarted"
  • "NativeApplicationStarted"

These events are emitted when spacelet, application or native application is started. The core sends to listeners a JSON result object containing a manifest object and an array of service objects. For spacelets the services are of type open and for applications and native applications the services are of type open, open_locale or both.

{
manifest: object,
openRuntimeServices: array
}

  • "EdgeSettingsChanged"

This event is emitted when the edge settings change. This event listener can be set only if administrator is logged in. The sessionId must be passed when the setEventListener is called. The RPC event request contains the EdgeSettings object.


  • "CoreSettingsChanged"

This event is emitted when the core settings change. This event listener can be set only if administrator is logged in. The sessionId must be passed when the setEventListener is called. The RPC event request contains the CoreSettings object.

Close
copyright © Spaceify.org 2014