RookProgramming
Topics in Phoenix-Channels
So I got my first chatroom up and running. I just have one question I notice I can make a topic have sub topics on one channel i.e. room:* how would I go about making a new chat rooms for each new sub topic. I’m a bit confused, is this possible or can I only create one chatroom per channel ? Thanks for the help I am really excited about learning Elixir !
Also, I noticed my chat messages are visible in every subtopic, is there a way to ensure that messages only are visible in it’s own subtopic/chatroom.
Most Liked
RookProgramming
Thanks a million, I will try this after I get back from work !!
Zesky665
If you use topic Room:SubTopic_ID for a subtopic, that’s just a new channel for just that one chatroom.
I usually use this to ensure that a message only gets sent to the appropriate channel topic.
broadcast!(socket, "topic:#{subtopic_id}:new_message", msg)
If you want to load older messages, you’ll need to do a bit of legwork. This would mean writing a query for loading older messages and running it in the :after_join channel event.
Also you’ll need to add them to the chat in the front end.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








