Sending user-specific messages

So far, we have crafted a relatively rich application using different types of broadcast messages.

For example, when a new comment is written, it's sent to every client. Only the clients actually displaying the relevant image will update anything. But the message was sent nonetheless. Also, when a user enters a new chat message, it's sent to everybody. For these use cases, this solution is fine. WebSockets make the process quite efficient.

But there are definitely scenarios when we want to send a message to just one subscriber. A perfect example we'll pursue in this section is adding the ability to "@" a user with a chat message. We only want such a message sent to that specific user. What would be even better? ...

Get Learning Spring Boot 2.0 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.