webinos/Webinos-Platform — pull request #472 by jplyle (2013-02-19 17:55:16+00:00)
Title: Intra-zone notification api

Jira issue: http://jira.webinos.org/browse/WP-523

This new, internal API will be used to broadcast messages to applications within a personal zone. The primary use case for this API is when a new user attempts to connect to your personal zone. This even needs to trigger some kind of notification locally with the user to approve/reject the request. This is implemented in this pull request.

This API provides two functions:
* subscribe
* respond

Subscribe registers the service object with the PZH such that it can receive event messages and cancel messages. Event messages describe a new notification, cancel messages describe the cancellation of a notification (e.g., if another device has responded). The respond function allows the application to reply to a service message with additional information, should that be necessary.

This service is hosted by the PZH. The PZH can internally trigger events with the following internal API available to the node process:

Notifications.sendFromInternal(pzh.serverName, "This is a notification message", idcallback, resultcallback);

The idcallback returns a unique ID for that notification message, and the result callback is invoked when a response to the message from an application is received.

The PZH might want to cancel an notification, particularly if a response has been received from one device. Notifications can be cancelled through:

Notifications.cancelFromInternal(pzh.serverName, notificationid, success, error);

Jira issue: WP-523