I have STOMP client written on JS, which have this code:
function connect() {
var socket = new SockJS('/our-websocket');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
console.log('Connected: ' + frame);
stompClient.subscribe('/user/topic/private-messages', function (message) {
showMessage(JSON.parse(message.body).content);
});
});
}
Is any way to send username as parameter / attribute on subscribe? Now I have DefaultHandshakeHandler implementation with determineUser() method:
override fun determineUser(
request: ServerHttpRequest,
wsHandler: WebSocketHandler,
attributes: MutableMap<String, Any>
): Principal? {
return super.determineUser(request, wsHandler, attributes)
}
This method calls when JS stompClient subscribes topic. Have any idea how to read username from it, or, maybe, any most popular way exists?