phoenix-channels

Elixir/Phoenix map for the channels payload

匆匆过客 提交于 2019-12-25 07:18:18
问题 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: (column name) is used for both Mike and John, but when passing through channels payload, I can only pass one map, where can't have both name: John, name: Mike at the same time. As I understood channels, we use a map(payload) that is send back to

How to set up Websockets with Phoenix behind Nginx?

笑着哭i 提交于 2019-12-24 03:44:11
问题 I'm trying to set up web sockets to go through Nginx to a Phoenix app but keep getting a 403 error. Can anyone advise the correct configuration to make this work in production - development env is fine. My Nginx conf: upstream phoenix { server 127.0.0.1:4000 max_fails=5 fail_timeout=60s; } server { server_name <app-domain>; listen 80; location / { allow all; # Proxy Headers proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host;

Phoenix Channels - broadcasting from controller - how to find current_user?

大城市里の小女人 提交于 2019-12-24 00:34:16
问题 I have an app where I broadcast some submissions for forms in the submission_controller, like this: Formerer.Endpoint.broadcast("forms:#{form.id}", "new_submission", payload) However, what I try to do now, is to make sure that only the current_user has access to the submissions broadcasted for its forms. (eg, current_user will have no way to see the submission for "forms:2" if form 2 belongs to another user). I manage to do this in the channel join action by filtering the forms only for the

Broadcast to different channel Phoenix 1.1.6

六月ゝ 毕业季﹏ 提交于 2019-12-10 16:45:12
问题 I'm trying to broadcast to a different channel in my app but I can not get it to work. Also I trying to write a test but I'm not sure how. From what I can gather I succeed in broadcasting the message from the notification_channel but it's not received in chat_channel. Notification should send to chat. notification_channel.ex def handle_in("new:group:recommendation", msg, socket) do payload = %{ message: msg["message"], url: msg["url"], title: msg["title"], user_name: get_name_of_user(socket

Phoenix - return Ecto query results to a specific client

醉酒当歌 提交于 2019-12-08 02:43:46
问题 I'm currently trying to devise a scheme where the following happens. Client A is subscribed/connected to topic/channel T . A sends a message in the form of a select query to T . Only A receives the query results, no other subscribers. Is this even possible using Channels? The main reason I chose Channels was for the excellent websocket support - however I'm open to other Phoenix solutions. 回答1: Yes, Channels should do the work you want. You can push the query results down to the user who sent

How to keep a user subscribed to every chat it is following

。_饼干妹妹 提交于 2019-12-06 15:05:59
问题 Thats the messenger's facebook UI If you were implementing that with phoenix (elixir framework) Would you create one phoenix-channel for one chat? Which will implies that you client (mobile, web etc...) will have to open one channel for every chat it is suscribed at Which will implies that if there is 2000 chats he is suscribed at, he will have to open 2000 channels (client load). Would you create one phoenix-channel for one user? Which will implies that your client (mobile, web etc...) will

Phoenix - return Ecto query results to a specific client

百般思念 提交于 2019-12-06 08:43:43
I'm currently trying to devise a scheme where the following happens. Client A is subscribed/connected to topic/channel T . A sends a message in the form of a select query to T . Only A receives the query results, no other subscribers. Is this even possible using Channels? The main reason I chose Channels was for the excellent websocket support - however I'm open to other Phoenix solutions. Yes, Channels should do the work you want. You can push the query results down to the user who sent the query using push : def handle_in("new_query", %{"query" => query}, socket) do # do the query and store

How to keep a user subscribed to every chat it is following

倾然丶 夕夏残阳落幕 提交于 2019-12-04 22:23:32
Thats the messenger's facebook UI If you were implementing that with phoenix (elixir framework) Would you create one phoenix-channel for one chat? Which will implies that you client (mobile, web etc...) will have to open one channel for every chat it is suscribed at Which will implies that if there is 2000 chats he is suscribed at, he will have to open 2000 channels (client load). Would you create one phoenix-channel for one user? Which will implies that your client (mobile, web etc...) will have to open just one channel and Which will implies that for every incoming message you'll have to

Phoenix Channels - Multiple channels per socket

耗尽温柔 提交于 2019-11-29 15:22:58
I'm writing an application using Elixir Channels to handle realtime events. I understand that there will be 1 socket open per client and can multiplex multiple channels over it. So my app is a chat application where users are part of multiple group chats. I have 1 Phoenix Channel called MessageChannel where the join method will handle dyanamic topics. def join("groups:" <> group_id, payload, socket) do .... Let's say John joins groups/topics A and B while Bob only join group/topic B. When john sends a message to group/topic A, broadcast!/3 will also send that message to Bob too correct?

Phoenix Channels - Multiple channels per socket

亡梦爱人 提交于 2019-11-28 08:47:40
问题 I'm writing an application using Elixir Channels to handle realtime events. I understand that there will be 1 socket open per client and can multiplex multiple channels over it. So my app is a chat application where users are part of multiple group chats. I have 1 Phoenix Channel called MessageChannel where the join method will handle dyanamic topics. def join("groups:" <> group_id, payload, socket) do .... Let's say John joins groups/topics A and B while Bob only join group/topic B. When