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

Elixir Phoenix 1.6 - trying to pass token to browser, function nil.id/0 is undefined or private

I am working on a Phoenix 1.6 app. I used Ueberauth for authenication via GitHub, which was working. I set up a channel to post topics and comments, which authenticated users can do. Next, I tried to add a user token for use in the channel. I…
Fruno
  • 81
  • 10
0
votes
1 answer

How is state stored inside a room/channel?

I'm trying to use Phoenix Channels as a dead-simple game server. For the prototype, its only purpose is to sync player positions. However, before that happens, every client must be aware of all other clients' existence. When a new client joins the…
verified_tinker
  • 625
  • 5
  • 17
0
votes
1 answer

How can I connect to Phoenix channels from a Kotlin Android app?

I'm thinking of building a full-stack project with an Elixir Phoenix backend and a Kotlin Android client. The app will require real-time data for features similar to chatting, so I will have to use Phoenix Channels. After a quick research, I found…
0
votes
1 answer

How to broadcast to one socket_id using phoenix

In the docs there is this example but it only works for disconnects https://hexdocs.pm/phoenix/Phoenix.Socket.html#module-examples use Phoenix.Socket channel "room:*", MyAppWeb.RoomChannel def connect(params, socket, _connect_info) do …
bezzoon
  • 1,755
  • 4
  • 24
  • 52
0
votes
1 answer

How to handle messages from another process so that they are sent on an Elixir Phoenix channel

I have channels working perfectly based on the docs, and my application is receiving and re-broadcasting messages as expected: Here's the code that handles the channel: defmodule HelloWeb.RoomChannel do use Phoenix.Channel def…
Thomas Browne
  • 23,824
  • 32
  • 78
  • 121
0
votes
1 answer

How do I specify my own Phoenix Channel JSON Serializer?

In my endpoint, I've got something that looks like: socket "/socket", MarsWeb.UserSocket, websocket: [transport: Phoenix.Transports.WebSocket, serializer: {MarsWeb.JsonCamelSerializer, "~>2.0"}], I'm trying to replace the JSON serializer with…
cjm2671
  • 18,348
  • 31
  • 102
  • 161
0
votes
1 answer

Wire up Angular 9 with Phoenix.js

I'm trying to wire up Angular 9 as a client with phoenix.js to connect to existing phoenix channel. First, I created an angular app via cli command and I downloaded phoenix via npm install phoenix. Then I added phoenix path in angular.json …
bbusdriver
  • 1,577
  • 3
  • 26
  • 58
0
votes
1 answer

Ticking clock using Phoenix Channels

I'm trying to create a Phoenix Channel that just contains a clock that users can subscribe to. defmodule MyWeb.TimeChannel do use Phoenix.Channel def join("room:time", _message, socket) do schedule_heartbeat() {:ok, socket} end def…
cjm2671
  • 18,348
  • 31
  • 102
  • 161
0
votes
1 answer

Why my Absinthe GraphQL Subscription doesn't work?

My Schema: subscription do @desc "Subscribe to drawing change" field :drawing_change, :drawing do # arg(:drawing_id, non_null(:id)) config(fn _args, _resolution -> {:ok, topic: "*"} end) end end When I…
Mr H
  • 5,254
  • 3
  • 38
  • 43
0
votes
1 answer

random extra websocket connection to phoenix app?

Simple user websocket with a single channel. I copied this code word for almost out of the how to section in the phoenix guidelines. The first request is mine - it contains the user auth token from a facebook login response. As you can see this…
9_Dave_9
  • 694
  • 1
  • 7
  • 20
0
votes
1 answer

Presence Chapter Presence Phoenix 1.4.6 Guides raises for Identifier 'socket' has already been declared

I'm reading the Phoenix Guides 1.4.6 and I'm at the Chapter Presence. So I follow all the steps of this chapter and my console javascript complains for this: app.js:1 Uncaught Error: Module build failed: SyntaxError:…
rld
  • 2,603
  • 2
  • 25
  • 39
0
votes
1 answer

Phoenix Presence: How to rename "presence_diff" to something more domain specific?

Phoenix has a nice event for broadcasting presence changes called presence_diff. I've tried to find a way to rename this event to something more specific to my domain (agent_diff in my case). Does anyone know if there's an idiomatic way of doing…
gunnar2k
  • 185
  • 1
  • 13
0
votes
1 answer

How to handle clients status in Phoenix Channel

I've just followed Phoenix Channel and Presence Documentation from their official site. Things work fine as it's described. As Channel documentation, it has join callback so I can handle something when client joins specific topic. But why there's no…
Hongseok Yoon
  • 3,148
  • 8
  • 36
  • 51
0
votes
1 answer

Phoenix channels with Android client

I'm trying to create a websocket connection to my Phoenix app from an Android client. I'm trying to use this library but I'm running into this issue and I'm unable to successfully join a channel. Upon reviewing the source code of the above java…
Murcielago
  • 1,030
  • 1
  • 14
  • 24
0
votes
1 answer

Count open socket and channel connections in a Phoenix application

Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter this data by topic and other channel connection…
Murcielago
  • 1,030
  • 1
  • 14
  • 24