Open emmanuelmillionaer opened 10 years ago
Did you follow his "Running on Heroku" steps?
Are there errors in the JS console?
@ngauthier @emmanuelmillionaer I've seen that some people is having problem with websockets beta feature under Heroku (it's disable automatically and needs to be re-enabled manually), I'll check if that is the case and I'll re-enable it.
The issue doesn't seem to be the websocket connection, but the lack of way to have multiple clients (browsers) communicate between them. That would require a way to broadcast messages to all connected clients instead of only passing messages between one client and the server like in the chat example.
Or said differently: have one server running, open two different browsers on that chat and have the messages typed on one browser appear in the other.
And going further than that it would be nice to be able to send the messages from other processes than the server, for example in your background worker to signal updated content.
I have a app currently using websocket-rails ( https://github.com/depili/isk ) but since websocket-rails is currently unmaintained and has several bad bugs in it I have been looking into alternatives, for me tubesock would fit perfectly if it had some way to broadcast messages from different clients and processes.
@guilleiguaran @emmanuelmillionaer yes, please check the chrome dev console to see if there is an error with the socket connecting.
Also, I wrote this example a long time ago, not sure if it still works: https://github.com/ngauthier/sock-chat
@depili that is a separate issue, and it's not an issue with tubesock. Tubesock does not prescribe mechanisms for using websockets to communicate between clients, only between a client and the server. Tubesock aims to be the minimal base for using websockets via rack hijack and rails 4+. If you wanted to make a multi-client communication library, you have to pick a mechanism for communicating the messages from one client's request to another. In my sock-chat example I picked redis for this. You can also use postgresql's pub/sub. Or you could use global variables in a single-process app, or a myriad of other services and databases. This is why I didn't want to pick one for tubesock. The idea is that it is up to you as a developer to create that mechanism. And if you generalize it, share it! :)
Nick
First of all i want to say thanks for this awesome gem! Im not sure if i missunderstood something but i thought that with websockets i can communicate with several clients. I tried some demo code on heroku that is provided by @guilleiguaran : https://github.com/guilleiguaran/rails4-ws-test http://rails4-ws-test.herokuapp.com/ And noticed that i only chat with myself and cannot communicate with other clients. Now my question is if its possible to open channels for groups of clients ? Thanks and have a nice day!