function connect() {
// 'websocket' -- naming context
// 'api' -- servlet context
// 'stomp' -- STOMP endpoint
var socket = new SockJS('/websocket/api/stomp');
stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
stompClient.subscribe('/topic/messages',
function(messageOutput) { // JS Object <-- Java OutputMessage
showMessageOutput(JSON.parse(messageOutput.body)); // JS String --> JS Object
}
);
});
}
function sendMessage() {
stompClient.send('/channel/chat',
{}, // header
JSON.stringify({...}) // JS Object --> JS String
);
}