Channels, Topics, Sockets in websocket

#1

Hi
I am working with Websockets for a couple of days and encountered some questions which I couldn’t find the answers in AdonisJs Documentations
I hope you help me with them :slight_smile:

  1. How to get a list of all Channels ( in server side )
  2. How to get a list of Sockets connected to a channel and topic ( in server side )

By having the answer of above questions it’s possible to iterate a channel and emit a message to all sockets of it, but if there is a simpler way :

  1. How to emit a message to a channel and topic

Thanks for your attention

0 Likes

#2

Yes, there is no API to get channels lists. However you can broadcast to all sockets connected to a given topic like mentioned in the docs https://adonisjs.com/docs/4.1/websocket-server#_broadcast_anywhere.

What’s the use case of broadcasting across channels?

0 Likes