HTML and CSS Reference
While we've walked through building a very simple game to show messaging over
WebSocket, there are many ways you can extend this game to make it more fully featured
and even exciting. When playing rock-paper-scissors in person, finding out the winner is
part of the excitement of the game. In an online environment, that's not quite the case.
Declaring the winner would be a simple but significant enhancement to the app.
Another extension is to make the game more secure. Rather than relying on
application logic to hide the opponent's move, you could centralize the game logic by
creating a dedicated queue that accepts the moves, and another one that distributes the
results. This logic would prevent players (or their browsers) from discovering the moves
in advance. Additionally, you can use topics to inform all players about the game results,
giving winning players publicity.
To improve player interaction, you could:
Automatically match up lonely players who don't have
opponents. A queue would be ideal for round-robin match
Build a bot that uses artificial intelligence that players can choose
as an opponent.
The Future of Web Messaging
Combining messaging concepts with low latency WebSocket communication opens
the door to myriad incredible applications. As we have seen in this chapter, real-time
collaborative “peer-to-peer” web and mobile applications can be built very easily. These
applications can include shared document editing, interactive social presentation and
learning tools, as well as social software with real time activity streams. Almost any type of
audience can leverage such apps, including the consumer marketplace, education, health
care, and transportation.
Another key application of web messaging is in the realm of machine-to-machine
(M2M) communication. M2M, sometimes referred to as the “Internet of Things” (IoT),
focuses on connecting everyday objects to the Internet. Implementing smart meters to
track and automatically report utility usage, interacting with home appliances (such as
checking if the door is locked or if the oven is turned off ), installing credit-card-sized
capable computers (such as the Raspberry Pi), monitoring devices and moving vehicles,
telemetry, and augmented reality are just a few of the use cases that M2M addresses.
Most modern real-time enterprises employ a corporate services architecture as
part of an efficient IT infrastructure. Diverse client facing or internal applications make
requests to common services to efficiently deliver revenue and productivity. The notion
of an Enterprise Service Bus (ESB) has been an accepted model for global corporations
for more than ten years. WebSocket now allows these enterprise services to be extended
securely to any web device allowing a more collaborative relationship with customers,
partners, and mobile employees.