Where would I store topic id?
As for socket, I can use:
def join("topic:" <> topic_id, _params, socket) do
...
socket= assign(socket, :topic_id, topic_id)
{:ok, socket}
end
That was at socket scope, but my users can join multiple topics at the same time, meaning that the above code will override the topic_id each time a new topic is joined, is that true?
What if I want to know which topic id is active in the handle_in
?
for example:
def handle_in("new_message", params, socket) do
# what is the active topic id here?
end
I though of this:
def handle_in("new_message:" <> topic_id, params, socket) do
# now, I know that topic_id is the active topic
end
Is there another way to do this? or this is how its done?