O'Reilly logo

Mobile and Web Messaging by Jeff Mesnil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Web Messaging with STOMP

In this chapter, we will write a Web application that sends and receives messages using the STOMP protocol over HTML5 Web Sockets.

In Locations Application Using STOMP, we described the Locations application. In this chapter, we will write the Web application that consumes the device’s GPS position to display them on a map and sends text messages to the devices.

Diagram of the +Locations+ Web application
Figure 3-1. Diagram of the Locations Web application

About the Code

All along the chapter, we will show all the code required to run the application.

The whole application code can be retrieved from the GitHub repository in the stomp/web/ directory.

HTML5 Web Sockets

Web Sockets is a recent features of Web browser that provides a bi-directional and full-duplex communication channel over a single TCP connection between the Web browser and the Web server. Before Web Sockets, communication was only one-way: the browser initiates the communication by sending a HTTP request to the Web server which replies with a HTTP response. The server could not send data to the browser without the browser having first sent a request. There exists some techniques to provide a bi-directional HTTP (such as HTTP long polling and HTTP streaming) but they have significant issues as described in (to come).

Thanks to HTML5 Web Sockets, it is now possible to have two-way communication between the browser and the server. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required