jc
09/09/2024, 2:59 PMonmessage
function on the cfwebsocket.js
file. The following link should have those specific lines highlighted for you.
https://github.com/GiancarloGomez/ColdFusion-Realtime-With-WebSockets-Demo-Code/blob/master/html-to-coldfusion/cfwebsocket.js#L34-L57brendan
09/09/2024, 9:10 PM<div hx-ext="ws,transform-response" ws-connect="<ws://127.0.0.1:8585/cfusion/cfusion>" ws-send hx-trigger="load"></div>
<script>
document.body.addEventListener('htmx:wsConfigSend', function(evt) {
var subscribe = {"type":"welcome","subscribeTo":"feed","appName":"snake"}
evt.detail.messageBody = JSON.stringify(subscribe);
});
htmx.defineExtension("transform-response", {
transformResponse : function(text, xhr, elt) {
var data = JSON.parse(text).data;
return data;
}
});
</script>