O'Reilly logo

Instant Vert.x by Simone Scarduzio

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

Quick start – IRC-style chat with TCP server and event bus

As a second example, let's show off a bit of what event bus can do. This is a TCP server that fans out messages received from one client to the rest of the connected clients.

Note

This is an event bus-based variation of the classic "fan out" example that can be found in official documentation of Vert.x. The original example keeps a set of client sockets (one for every connected client) and iterates over them every time a new message is received. With this one however, we will demonstrate how the publish-subscribe feature offered by this framework, keeps the code simple by saving the hassle to keep updated and iterate over a set of client sockets.

Step 1 – fresh start

  1. In a new folder called, ...

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