Messages from more than one topic

Can a socket subscribe to more than one topic simultaneously?

1 Like

Yep, it does so via your Endpoint’s subscribe method, check hexdocs in the phoenix endpoint help to see the call and the format of the messages it sends you. :slight_smile:

1 Like

Thanks @OvermindDL1…one more thing.I am going through the documentation here and right at the bottom it says

id(Phoenix.Socket.t) :: String.t | nil
Identifies the socket connection.

Socket id’s are topics that allow you to identify all sockets for a given user:

Isn’t it one socket per user that handles all the communication? Why would a user need more than one socket?

1 Like

Imagine that they have more than one tab open, they will have a socket per webpage, just how it works. The only time I’ve used the id for the socket itself is when I want to kill all the active sockets of a user, which I do when they log out. :slight_smile:

2 Likes

@OvermindDL1 thanks a lot for that

1 Like