Questions tagged [phoenix-channels]

Phoenix framework's channels give the tools to organize the code and the communication among users while keeping the connection opened for live messages updates, its transportation-agnostic, so it can use different protocols, like websocket or log polling..

A Phoenix channel is a conversation. The channel sends messages, receives messages, and keeps state. We call the messages events, and we put the state in a struct called socket. A Phoenix conversation is about a topic, and it maps onto application concepts like a chat room, a local map, a game, or in our case, the annotations on a video. More than one user might be interested in the same topic at the same time. Channels give you tools to organize your code and the communication among users. The concept that makes channels so powerful in Elixir is that each user’s conversation on a topic has its own isolated, dedicated process.

102 questions
0
votes
1 answer

List of all listeners on channel

How is it possible to see all listeners on channel at some moment ? (I mean phoenix-js and client-side js code) Something, like this: channel.eventListeners = ['event1', 'event2'] ...
Max P
  • 1,439
  • 3
  • 15
  • 33
0
votes
1 answer

How can I update color of button in real time?

I have an index page, when a user logs in, it shows all tables (button of tables) in the database.Table can have an order. So, it works like when a user clicks a table, it redirects to the create path of order and create an order. Or if a table has…
D.R
  • 829
  • 4
  • 16
  • 30
0
votes
0 answers

Passing data from action to channel gracefully

How to pass data from Action to Channel in Phoenix. Let's consider that we have controller Controller and channel Channel, how do send data from Action in Controller to corresponding Channel connection. The "solutions" we came up with are ugly, we…
Haito
  • 2,039
  • 1
  • 24
  • 35
0
votes
0 answers

How to test channel with Phoenix.ChannelTest.close/2

I have a test that starts up a socket connection and subscribes and joins a topic. I then push a message to the channel which does some work and persist some data. I then use ChannelTest.close/2 on the socket which simulates the client closing the…
Alejandro Huerta
  • 1,135
  • 2
  • 17
  • 35
0
votes
1 answer

Multi tenant phoenix channels

In the past I've implemented multi tenant systems and used the request host header to segregate users between tenants. My first thought was to take the same approach but with websockets but I hit a couple of issues: 1) The host header does not…
opsb
  • 29,325
  • 19
  • 89
  • 99
0
votes
1 answer

How do I access the full URL of a websocket request inside an elixir phoenix channel?

In my phoenix channel I need to do some things that requires me to know what domain the request was made for. Example: https://beta.example.com vs https://www.example.com. Is there any way to access that information from or pass that information to…
tslater
  • 4,362
  • 3
  • 23
  • 27
0
votes
1 answer

Elm application stops receiving phoenix channel broadcasts

Elm, phoenix, and elixir are quite new to me so I thought I would make channels test app simple example app to test the use of phoenix channels. The app has other stuff in it too because its made from old "parts" but bear with me on this. The idea…
Jukka Puranen
  • 8,026
  • 6
  • 27
  • 25
0
votes
1 answer

Adding custom functions to channels

I wish to modify Chris McCord's chat example to add additional functionality. Basically, I want the JavaScript client to have access to a number of convenience functions, such as getUsersInRoom(room_id), is_online(user_id), etc., using JSON. But I'm…
ankush981
  • 5,159
  • 8
  • 51
  • 96
0
votes
0 answers

Elixir/Phoenix websocket error

I'm trying to connect from a JS application to a websocket connection in Phoenix/Elixir, however, now matter what I try, I get ERROR: [info] GET /socket/websocket [debug] ** (Phoenix.Router.NoRouteError) no route found for GET /socket/websocket…
ellimist
  • 586
  • 3
  • 12
0
votes
1 answer

Elixir/Phoenix map for the channels payload

Well, I am looking for a good way to pass multiple elements (same column name) that I've retrieved from db into the channels payload. For example: ppl = Repo.all(People) will return two results with id: 1, name: Mike, id: 2, name: John. The name:…
Ilya
  • 1,120
  • 1
  • 12
  • 33
0
votes
2 answers

How to use Phoenix.Channel.reply/2 for async reply to channel push

I'm trying to extend the example of Phoenix.Channel.reply/2 from the Phoenix documentation into a fully working example of asynchronously replying to Phoenix channel/socket push events: Taken from…
Marcel
  • 367
  • 1
  • 12
-3
votes
1 answer

how can i access data inside map in elixir

i have simple chat app written using phoenix framework. i want to access some data inside the socket this is the method im using for that def join("room:" <> _user, _, socket) do IO.inspect socket send self(), :after_join {:ok,…
smartechno
  • 470
  • 1
  • 5
  • 18
1 2 3 4 5 6
7