Genie.jl icon indicating copy to clipboard operation
Genie.jl copied to clipboard

Websocket Documentation Missing Website Integration

Open jackn11 opened this issue 1 year ago • 4 comments

In the web socket documentation found here https://genieframework.github.io/Genie.jl/dev/tutorials/17--Working_with_Web_Sockets.html, there are no examples of web sockets being implemented with any other html. They are only implemented on their own with the response from the Assets.channels_support() function. Thus it is very unclear to me how I can include this in a Genie website that contains html. I started a discourse here as well https://discourse.julialang.org/t/how-to-add-websocket-to-genie-site/84976.

jackn11 avatar Jul 29 '22 13:07 jackn11

@essenciary I was hoping you could help me figure out how to add a websocket to an MVC app. I have read the entire genie.jl documentation and still cannot figure it out. Please let me know how this can be done.

jackn11 avatar Aug 02 '22 01:08 jackn11

You put <% Genie.Assets.channels_support() %> inside the HTML of your web page and this outputs a <script>...</script> tag and sets up routing and everything else.

This in effect, in the browser, gives you access to a Genie.WebChannels object and you can call Genie.WebChannels.sendMessageTo(...) to push data over the websocket.

On the server, you define the corresponding channel(...) to catch/route/delegate these websockets requests to your handler functions.

essenciary avatar Aug 02 '22 12:08 essenciary

We could include a simple client - server example using web pages in the docs.

essenciary avatar Aug 02 '22 12:08 essenciary

Thank you very much for your answer, that worked for me!

That info should definitely be included in the docs. It would be very helpful.

jackn11 avatar Aug 03 '22 16:08 jackn11