我正在将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
在日志中。
我看不出哪里出问题了。