小编and*_*ang的帖子

为什么Spring SendToUser不起作用

我只是跟进从春天的指令发送回响应特定用户,而不是广播消息instead.but到底,无应答消息可被送回.

这是我的js代码:

var stompClient = null;
function setConnected(connected) {
    document.getElementById('connect').disabled = connected;
    document.getElementById('disconnect').disabled = !connected;
    document.getElementById('conversationDiv').style.visibility = 
            connected ? 'visible': 'hidden';
    document.getElementById('response').innerHTML = '';
}
function connect() {
    var socket = new SockJS('reqsample');
    stompClient = Stomp.over(socket);
    stompClient.connect({}, function(frame) {
        setConnected(true);
        console.log('Connected: ' + frame);
        stompClient.subscribe('user/queue/resp', function(resp) {
            var body = JSON.parse(resp.body);
            showResp('cmid:' + body.cmid + ',reqName:' + body.reqName
                    + ',custNo:' + body.custNo + ',qty:' + body.quantity);
        });
        stompClient.subscribe('user/queue/errors', function(resp) {
            var body = JSON.parse(resp.body);
            showResp(body);
        });
    });
}
function disconnect() …
Run Code Online (Sandbox Code Playgroud)

spring stomp websocket sockjs

2
推荐指数
1
解决办法
4243
查看次数

标签 统计

sockjs ×1

spring ×1

stomp ×1

websocket ×1