-
Notifications
You must be signed in to change notification settings - Fork 180
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
How do I simply push messages over WebSockets? #452
Comments
Here is one possible solution: Paste into one REPL:
Paste into a different REPL:
I don't think you need to do this in different REPLs, but it makes the demonstration a bit more convincing (to me). In the first block of code, the line |
Thank you for your answer. I'm sorry for my late reply, the project was on hold for a bit. Your solution works perfectly, but is not entirely applicable to my situation. I think I didn't quite manage to word my question correctly. Please allow me to rephrase my situation: I have some processes running in Julia. These processes obtain results at unpredictable intervals. The results of these processes should be pushed immediately to a browser-based javascript client. I have figured out the JavaScript part, but how do I get Julia to push messages over the WebSocket non-periodically without holding up the rest of my code AND without having to wait for requests from the client? |
@arjensuijker Not sure if it's feasible to switch to Genie at this point in your project, but Genie provides infrastructure for WebSockets messaging over the WebChannels API. You can register WebChannels, have JS clients subscribed to individual channels, and then receive and push messages over the channel (or broadcast over all the channels). |
I looked at Genie as an option, but it seemed like it would be a little overkill for my small project. But if it provides better websocket support for my situation then I might try it. Genie looks like a great project anyway, will be fun to try out. I couldn't find good documentation on the webchannels / websockets though. Could you point in the right direction to get started? |
The feature is overdue for documenting :) If you're not in a big hurry, I can add a section on it over the weekend, it's been on my todo for a while so I can move it up a bit. |
I would also be interested in documentation for those features and a simple working example if possible. |
That would be great! As an added advantage, you would be adding even more unique selling points to Genie ;) . |
@essenciary Any progress? Can I help? |
@arjensuijker on its way! Thanks for the help offer, will appreciate feedback on the docs and code once it's up! Need a few more days though, busy period! |
@arjensuijker https://genieframework.github.io/Genie.jl/documentation/17--Working_with_Web_Sockets.html -- let me know if this is what you're looking for, feedback appreciated! |
Not an issue but a question. I'm having a lot of trouble figuring out how to do something so simple. I want to establish just one websocket from julia as the server and then push json through that socket at random intervals from elsewhere in my code. Any suggestions?
The text was updated successfully, but these errors were encountered: