How to add WebSocket to Genie Site?

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.

2 Likes