anurag.peshne
Phoenix websocket: how to send message to one user
Hello,
I’m new to Phoenix and I’m following this tutorial Channels — Phoenix v1.8.8 to implement something similar to chat application as described in that tutorial.
That article talks about how to broadcast a message, I want to send a message to a particular user. And I couldn’t find something similar to send. How I can do that.
Also, to do this, do I have to save all the connected socket objects in another process’s state, maybe using a map which maps username → socket.
Most Liked
kokolegorille
The trick is to broadcast to a specific user with
socket.endpoint.broadcast!(“user:#{id}”, message, payload)
amnu3387
AFAIK the phoenix team is not yet charging for creating topics, so it’s free.
(j/k)
The cost will probably be one entry with one term in an ETS table? How that translates into “really” useful information I’m not sure.
axelson
Quite cheap, I wouldn’t worry about it at this point.
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










