Phoenix private channel to single, anonymous user

Hi all,
in my Phoenix app I have multiple users, but all of them are anonymous, I am not planning any authentication. User launches some operation, which is running on the server side and may be long, and may send some information back to the browser (“hey, I finished part1! be patient, only 3 to go!”).

Is it possible to create a channel which would be private - just to the single user, even to the single browser tab? I want to have a communication between browser and Phoenix but not broadcasted it to all.

My current approach is this:

  • user sends “login” request in a traditional way (AJAX)
  • phoenix creates some unique ID (like UUID or based on the current time?), creates the room:uuid and returns this uuid to the client
  • client connects to room:uuid, which since now has one and the only one habitant

Does such approach sound reasonable? For me, it looks quite overcomplicated, maybe there is a better way to accomplish this?
How to detect client disconnect to not keep this room forever?

Or should I do it in more traditional way, AJAX + polling every few seconds.

1 Like

Easy enough to do, however you identify their ‘work’, even by serializing a PID for example, just have that be part of the topic name or so, anything that would be a unique ID is fine, even better if you stuff it into a token for security.