tl;dr
Is there a way to get a list of pids subscribed to a phoenix pubsub topic?
My use case:
– setup
- many many-to-many chat room channels where messages are posted
- once a message is posted, some additional individual action (for example, a push notification) needs to be performed for each member of that chat room
– my current “solution”
- use
broadcast_from!
withintercept
andhandle_out
, but apparently it encodes each message as many times as there are members in the chat room which is suboptimal
– my “ideal” solution
- use
broadcast_from!
withoutintercept
andhandle_out
to encode the broadcasted message only once, and trigger the additional actions inhandle_info
of the socket process or a channel process, whatever phoenix uses, but for that I’d need their pids
I’ve skimmed through pubsub source code, but al the functions which list pids seem to be private …
There is a way to get the local pids though
https://github.com/phoenixframework/phoenix_pubsub/blob/master/lib/phoenix/pubsub/local.ex#L121-L139