I am trying to understand how channel works and read the doc on phoenixframework.
I started with socket handlers and could not understand this setence:
Phoenix holds a single connection to the server and multiplexes your channel sockets over that one connection.
What for server does it mean here?
So please check, if I understand what you mean:
The server creates for every socket connection a process right? If 5 users connect to the server, then the server will create 5 processes?
When a user writes something into the topic, then the topic specific process will broadcast to other 4 users through which socket?
What do you mean here:
it multiplexes out the topic connections through the single socket connection.
Can you please draw it for better understanding?
Each user has their own connection to the server. Each connection has it’s own process on the server, holding the socket for that connection. A user can be connected to multiple topics, but all communication for those topics goes over the one socket, which is what is meant by “multiplexed”. When a message is broadcasted to all users of a topic, the message is sent over every socket associated with a user joined to that topic. Make sense?
It makes sense. Thanks so much.