com.talk2object.plum.view.web.plumresources.push.plum-push.js Maven / Gradle / Ivy
The newest version!
var stompClient = null;
function connect(topic) {
var socket = new SockJS(window.location.href + 'hello');
stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
console.log('Connected: ' + frame);
stompClient.subscribe(topic, function(greeting){
json = JSON.parse(greeting.body);
showResponse(json.action, json.id, json.content);
});
});
}
function disconnect() {
if (stompClient != null) {
stompClient.disconnect();
}
setConnected(false);
console.log("Disconnected");
}
function sendName() {
var name = document.getElementById('name').value;
stompClient.send("/app/hello", {}, JSON.stringify({ 'name': name }));
}
function showResponse(action, id, html) {
if(action=="replace")
$("#"+id).replaceWith(html);
else if(action=="append")
$("#"+id).append(html);
else if(action=="remove")
$("#"+id).remove();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy