Search code examples
elixirphoenix-frameworkphoenix-channels

Is there a way to get presences list inside a controller?


I'm trying to get the presences list inside a phoenix controller, but I need the socket to use the function Presence.list(socket).

Anyone knows how to use Presence.list(socket) inside a controller? The reason why I am trying this is that I want to find a different user in my database than those connected to the channel (presence list).


Solution

  • The best way that I found was: Phoenix.Presence.list(MyApp.MyChannel, "my_topic")

    There are the reference: Phoenix.Presence.list