STOMP SocketBox Demo

This is a demo that uses WebSockets to communicate with the server. It is built using CFML (running on BoxLang) and our new SocketBox library. SocketBox is a new feature built into CommandBox and the BoxLang MiniServer to be able to easily create WebSocket servers in CFML that work for Adobe ColdFusion, Lucee Server, or BoxLang!

This demo uses the STOMP broker functionality, which sits on top of the simple websocket functionality and adds topic and routing semanatics. You can use any Stomp.js client library and create a STOMP connection, over which you can subscribe to topics, and send messages to different desitinations. We are using direct routing, topic routing, fanout routing, and distribution routing as well as server-side listeners.

All streaming data below is generated randomly by a daemon thread on the server to mimic real-time information which broadcasts out messages regardless of whether or not there is a browser with a WebSocket connected. If you open two tabs, you'll see they are reveiving the same data. Open your browser's console to see debug info from the Stomp.js library. As you subscribe and unsubscribe from different topics, you'll see the incoming messages change based on your subscriptions, which are authorized and tracked on the server.

Full source code for this demo available here: bdw429s/socketbox-stomp-demo. You can run this yourself on the latest BoxLang MiniServer or on CommandBox 6.1+ and any CF engine.


When subscribed to this topic, you receive the current server time every second.




Subscribe to this topic to receive a stream of lucky numbers.

Here you have the choice of 3 topics containing different types of food. These use a topic exchange with wildcard for matching.





This button sends a message to the server, which replies over a private channel that only your STOMP session can see, creating an RPC-style callback for low-latency round trip server hits that don't require an Ajax call.


Family Messenger


Utilizing a series of fanout exchanges, we can broadcast messages to different groups of family members. All members in the group receive the message. The "assign a chore" button uses a distribution group, evenly distributing chores to a single family member at a time.

           

Mom

Dad

Susie

Timmy