Palm webOS is designed around the needs of connected applications, including the deep integration of web or cloud services into the platform. The intention is to create a platform supporting not just client application UIs and services, but web services as well. This extends the platform beyond the boundaries of the device to the Web itself.
The initial webOS cloud service offering is Mojo Messaging, an XMPP-based messaging service supporting notifications from web services to the device and eventually between device applications and services. Push notifications are much more power-efficient and extend battery life. Applications will be notified when there is a service update, eliminating the need to poll. In addition, the Mojo Messaging architecture extends the messaging model to enable client applications and services to communicate with each other.
You will typically use Mojo Messaging following these basic steps:
Create an endpoint, to which a key is returned.
Share the key with the cloud service from which you need updates.
Subscribe to the endpoint with a callback to receive messages.
Wake when a message arrives from the cloud on the defined callback.
Start by creating a notification endpoint. This registers the receiving application with the messaging service and establishes a publishing key for notifications:
this.controller.serviceRequest("palm://com.palm.pubsubservice", { method: "createEndpoint", parameters: { endpoint: "com.palm.app.news.newstories", description: "When new stories are published, notify the News application" }, onSuccess: this.createSuccess.bind(this), onFailure: this.createFailure.bind(this) });
Share the publishing key with any service that would send notifications to the applications; typically this is done with an HTTP POST request.
You will retrieve the publishing key from the response object
returned in the onSuccess
case, as outlined in Table 9-7.
Subscribe for notifications published to the endpoint and renew the subscription after each notification:
this.controller.serviceRequest("palm://com.palm.pubsubservice", { method: "subscribe", parameters: { endpoint: "com.palm.app.news.newstories", subscribe: true }, onSuccess: this.notificationHandler.bind(this), onFailure: this.subscribeFailure.bind(this) });
Whenever a notification comes into the device from the endpoint, it
is dispatched to the application through a callback to the function
defined as the onSuccess
handler.
The Cloud services are in beta release at this time, so we aren’t going to look at them in detail here. If you’re interested in this class of service or the Messaging service in particular, you should view the latest information at http://developer.palm.com.
3.131.38.208