concept resourceful pubsub in category sails

This is an excerpt from Manning's book Sails.js in Action.
In this chapter, we’ll differentiate WebSocket events from the HTTP request/ response scheme we’ve used in prior chapters. We’ll show Sails virtual request integration that makes WebSockets work like regular ol’ requests but with access to the WebSocket via the req dictionary. With access to the user-agent’s WebSocket, we’ll introduce the concept of using rooms to organize those connected to the Sails WebSocket server and currently viewing a particular video. We’ll enable user-agents to chat using lower-level methods like sails.sockets.join() and sails.sockets.broadcast() on the backend and io.socket.on() on the frontend. Next, we’ll transition to Sails resourceful pubsub (RPS) methods, replacing sails.sockets.join() with Video.subscribe() and sails.sockets.broadcast() with Video.publish-Update() on the backend. Finally, we’ll take a closer look at using resourceful pubsub with blueprint CRUD actions, which have added features regarding WebSockets. If that seems like a lot of material, don’t worry. We’ll take each topic step by step with examples. Let’s get started.
In addition to the WebSocket client and low-level backend WebSocket methods, Sails provides an automation layer called resourceful pubsub. Each model, also referred to as a resource, is automatically equipped with methods for joining connected WebSockets to event notifications when records are created, updated, and/or deleted. In Brushfire, you want each video record to have its own unique room such as video1. Currently, you’re creating the room name by concatenating the word video with the id of each record. When the browser user-agent’s WebSocket accesses a particular video player page, you join the WebSocket to the room with the concatenated name.