- Open url http://localhost:8080/websocket
- Open browser developer tools and go to console
- Copy and paste the code for stomp from cdn => https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js inside the console
- Copy and paste the code for sockjs cdn => https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js inside the console
- Copy the script to connect
- run "connectRome()" inside console
- Check for new messages in console
- For London do the same thing in a new tab
Script
function connectRome() {
var socket = new SockJS('http://localhost:8080/websocket');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
stompClient.subscribe('/topic/Rome', function (greeting) {
console.log("Received message: " . greeting)
});
});
}
function connectLondon() {
var socket = new SockJS('http://localhost:8080/websocket');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
stompClient.subscribe('/topic/London', function (greeting) {
console.log("Received message: " . greeting)
});
});
}