Private Channels/Sockets?

Basically, I want to have my frontend only communicate through websockets, however, no user really needs to be in the same room nor should they be.

Basically, I was thinking of having it so there would be 1 socket connection for the whole app, and then different pages would use join/leave different channels.

In terms of making channels private, I was thinking of generating a random a random key for the user to use on the frontend, and then using that as the identifier e.g. (“dashboard:ASLKSJNGKJAN”). Is this a good approach?

Or am i going over the top here and could just have them all join the same single channel, and instead of using broadcast I would just use reply or push - if so is this safe? E.g. no other users could intercept other users messages?

It is usual to have multiple channels over 1 socket connection. One can be used to receive public annoucement, one private to the user… to get individual notification… one for the room etc.

You can use a token to secure the socket.

You can use Presence to identify (and get the list of) each connection.

1 Like