Websockets combining chat and broadcast examples?

Looking at this example:


I’m trying to broadcast from the server, a message to the chat channel? I’m looking at the broadcast example and can get that to work but having difficulty merging the broadcast with the chat example.

I am curious if anyone has tried doing this and might have some sample code?

Maybe this will help someone:

Send message to channel using chat example.


<cfscript>

    test = WebsocketRegister("/ws/chat/{channel}", new ChatListener());


    channel = "213";
    message = '{
        "CHANNEL": "#channel#",
        "FROM": "Lucy",
        "MESSAGE": "test 123233",
        "TIMESTAMP": 1555949987950 }';
    test.broadcast(channel, message);

</cfscript>


<CFDUMP var="#test#">
<CFDUMP var="#test.getChannels()#">
1 Like