0

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 once did it by injecting it into .js file (hackathon), but that's uggly. I was thinking about whether is it possible to pass it via session, because first request of WS is get request, but I didn't found proper solution yet.

Consider authentication example. You acquire data via oauth callback and want to pass it to same user but on socket connection on a particular channel.

The problem is that data is aquired via callback. Let’s say that data is secret. I want it to be used in socket connection in particular channel

  1. Get data from callback (Controller)
  2. Do the thing i dont know
  3. Join channel with data from callback (Channel)

Any ideas how to do it properly?

Haito
  • 2,039
  • 1
  • 24
  • 35

0 Answers0