具有`user`(@SendToUser)的SockJS不起作用

时间:2019-11-29 14:25:08

标签: javascript java spring spring-boot sockjs

我正在将SockJS用作websocket协议,问题是...

$(function() {
    var socket = new SockJS('http://localhost:8080/endpoint')
    var stompClient = Stomp.over(socket)
    stompClient.connect({}, function(frame) {
        stompClient.subscribe('/user/market/price', function(payload) {
            // I was expecting this to receive messages, but it doesn't.
        })

        var splited = socket._transport.ws.url.split('/')
        var sessionId = splited[splited.length - 2]
        stompClient.subscribe('/user/' + sessionId + '/market/price', function(payload) {
            // While this does...
        })

        setTimeout(function() {
            stompClient.send('/private/market/price', {}, "")
        }, 2000)
    })
})

我使用springboot作为后端。我可以清楚地看到:

org.springframework.web.SimpLogging : Processing MESSAGE destination=/user/3320m5ir/stock/price session=3320m5ir payload=3320m5ir在日志中。

我看不出哪里出问题了。

0 个答案:

没有答案