How to terminate sockets from a channel topic in the Phoenix server side?

Suppose a room is public, everyone can join. However if the admin of the room sets the room to private, only a certain number of people can remain in the room; everyone else will be kicked out of the room.
How to kick people from the room in phoenix? Is there a function for that?
Or should I implement this functionality in the client side? I.e. broadcast a “private_room” event along with a list of user ids that can remain in the room, if the client isn’t in the list they should exist the room themselves.
Or is there a better way to implement this?

So a “channel” in the looser sense is just a bunch of channel processes sharing a common topic. So broadcasting a message is the means of informing active channel processes about the change in access to the “room” (topic). You can handle that broadcast msg on the server to make sure those clients actually stop.

1 Like