Mobile and Web Messaging: Messaging Protocols for Web and Mobile Devices

Mobile and Web Messaging: Messaging Protocols for Web and Mobile Devices

Language: English

Pages: 184

ISBN: 1491944803

Format: PDF / Kindle (mobi) / ePub

Learn how to use messaging technologies to build responsive and resilient applications for mobile devices and web browsers. With this hands-on guide, you’ll use the Stomp and Mqtt messaging protocols to write iOs and web applications capable of sending and receiving Gps and device sensor data, text messages, and alerts.

Messaging protocols are not only simple to use, but also conserve network bandwidth, device memory, and batteries. Using this book’s step-by-step format, author Jeff Mesnil helps you work with Objective-C and JavaScript libraries, as well as the protocols. All you need to get started are basic programming skills.

  • Understand basic messaging concepts and composition
  • Learn two common messaging models: point-to-point and publish/subscribe
  • Use Stomp to write an iOs application that sends Gps data, and a web app that consumes the data
  • Build an iOs app with Mqtt that tracks and broadcasts device motion data, and a web app that displays the data and sends alerts
  • Extend Stomp to filter, prioritize, persist, and expire messages
  • Take a complete tour of Stomp and Mqtt, including features not used in the book’s sample apps

HTML5: Up and Running

Crush It!: Why NOW Is the Time to Cash In on Your Passion

PHP for Absolute Beginners (2nd Edition)

Responsive Web Design by Example

Web Designer, Issue 195



















destination:/topic/device.2262EC25-E9FD-4578-BADE-4E113DE45934.location content-type:application/json;charset=utf-8 content-length:122 {"lng":-122.03254905,"deviceID":"2262EC25-E9FD-4578-BADE-4E113DE45934","lat":37.33521504,"ts":"2014-03-13T17:19:05+01:00"} ... This confirms that STOMP messages are effectively sent by the Locations application. ActiveMQ Admin Console In app_activemq_admin_console, we use the ActiveMQ admin console to check the broker configuration. We can also use this console

header, so we will pass an empty JavaScript literal object {}) A connectedCallback function that is called back when the client is successfully connected to the STOMP broker) // connection to the STOMP broker // and subscription to the device's position destinations // // the url paramater is the Web Socket URL of the STOMP broker function connect(url) { // creates the callback that is called when the client // is successfully connected to the STOMP broker var connectedCallback =

the handler: - (void)unsubscribe { NSString *topic = [NSString stringWithFormat:kAlertTopic, self.deviceID]; [self.client unsubscribe:topic withCompletionHandler:nil]; } We will call this unsubscribe method just before disconnecting from the MQTT broker from the dealloc method: - (void)dealloc { [self.motionManager stopDeviceMotionUpdates]; [self unsubscribe]; [self disconnect]; } Because we disconnect just after unsubscribing, we could skip that step and just disconnect from the MQTT broker.

knows that it must store its state) and closing the application. While the application is closed, we will modify the motions.html web application to send an alert message to the device alert topic with a QoS of 1 (At Least Once): function sendAlert(deviceID) { var message = new Messaging.Message("red"); message.destinationName = "/mwm/" + deviceID + "/alert"; // send the alert with a QoS of At Least Once message.qos = 1; client.send(message); } The client will not be available to receive the

console running at http://localhost:8161/hawtio>. Out of the box, you can log into the admin console using the admin / admin credentials. After you are logged in, you can check the mybroker resource in the ActiveMQ tree, as illustrated in Figure A-1. Figure A-1. The mybroker resource in the ActiveMQ web console One interesting attribute is transportConnectors. If you click on the attribute value, a pop-up screen opens and display all the protocols supported by ActiveMQ out of the box

Download sample