The core concepts of PushJS
Learn how PushJS works in the background and how it handles the client/message sending.
PushJS is a socket server where clients can connect to. It features a message queue with a FIFO system
It uses it's own protocol to communicate with and how to understand the client communication.
A device, such as a browser on a tablet or a smartphone for example, which is connected to PushJS is considered a client.
Every user/account will get their own global channel. A channel is nothing more than a room of
connected clients which are capable to communicate with and to each other.
Take a look at the following scheme. By default, any client that is connected to your app, is pushed into the global channel.
The global channel will dispatch system events and all your defined custom events. Once a client is into the global channel it is capable of creating a custom channel. Just like the global channel it will receive system events and custom events.
The only difference lies in the custom events/listeners. System events like CLIENT_ENTER will be dispatched in all channels whereas custom events will only be dispatched in a defined channel.
Some examples of a channel:
- A private one to one chat, this channel will contain no more than 2 clients
- A public chat, this channel will contain many clients
- A limited chat, this channel will contain a number of specified clients