New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drab Manually publish to socket #20
Comments
This is a known problem. I have it in my TODO list, but I still couldn't find a way how to resolve this. The issue is that you need a Drab Server, which launches when the socket is created - on the client connect. After disconnect, the Drab Server and the socket is gone. What we need, is a kind of permanent socket and Drab, which we could use for a background broadcasting. I've faced the similar issue while creating the presence demo. When user disconnects, there is no socket anymore, so I can't just broadcast a message to the others. I made an ugly hack there: got a random, connected socket and use it to broadcast. I will keep this issue opened until I find the way to solve it correctly. |
This issue is solved with 0.5.0 (coming soon). Now, with broadcasting functions, you don't have to use the socket, but the subject, which doesn't have to be related to the socket. |
Fixed in v0.5.0 |
Hello, Thanks looks awesome, just a question, I don't see in the guide / API any reference to the |
True, documentation is crappy in this topic. I am going to update it soon. Thanks for pointing it! In general, there are subject creating functions:
it corresponds to controllers with
|
And I can use this in a pure GenServer how? I should use |
You need to have browsers connected with Drab first, so you need commander(s). Drab broadcast works with browsers connected with Drab only. Then you can broadcast from any part of code |
Unfortunatelly, I can't reproduce it. Can you please mention the phoenix and elixir version? |
@johannesE, could you please try to get https://github.com/grych/drab-example and run: Drab.Core.broadcast_js Drab.Core.same_path("/"), "alert('a')" on that? |
When I run the example, I get |
What is the client (browser) version?
… On 19 Aug 2017, at 14:13, Johannes ***@***.***> wrote:
When I run the example, I get [error] The client's requested channel transport version "2.0.0" does not match server's version requirements of "~> 1.0" every few seconds.
I use elixir 1.5.1 and used phx 1.3.0 in my app.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub <#20 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAGK3srJmsfMy3R8rAD98FTxe7d5bA2dks5sZtFngaJpZM4N5aDz>.
--
Grych
|
Ah, but the broadcast is working in the example app. The browser is chromium |
FYI: I did not set up |
EDIT: drab-example uses Phoenix 1.2, so forget about point 2. I will need to reproduce the issue somehow. BTW Query is not required. Actually, |
My code is here: https://github.com/octotreat/todomvc. I was trying to build something like this: http://todomvc.com/. The transport version error only happened in the example application. In there I was using phoenix 1.2.4, like you. The only difference is the elixir version (1.5.1 instead of 1.4), so I'm guessing that is the problem there. It will probably go away once you upgrade the example app to phoenix 1.3.0. So I think we should not focus on that one now. |
Thx! I managed to reproduce this issue with fresh Phoenix 1.3 installation. Interesting that it does not appear when running 1.3 over application built in 1.2. |
Cool. :-) |
Actually the issue is because in P13 the endpoint is |
@johannesE, could you please check with the fresh drab from master. It should be fixed. |
Yes, fixed :) Thank you! |
Is it possible to have a separate gen server that then triggers an update for all connected clients using drab?
I have a GenServer that polls for data / transforms and then stores the results, what I want is to show a live feed of the resulting data whenever it changes in all the connected browsers.
What I had now is a recursive loop with a sleep in the drab method, ex:
It works but I wonder if there is a better way to do it. I would rather setup a GenEvent and let the GenServer send a notification that the data has changed so I can display it. This means I don't have to continually poll for updates like I do now in the above function.
Regards
The text was updated successfully, but these errors were encountered: