Can I add a request parameter to the SockJs constructor so that it can be sent to the server
I am initializing my SockJs url as
var protocols = ['xhr-polling', 'xdr-polling', 'xdr-streaming', 'xhr-streaming'];
var options = {protocols_whitelist: protocols, debug: true,server:tets};
_ws = new SockJS(url, null, options);
I want to send a request parameter like somesite / sockjs / info? someparam = tets "
Is it possible? The documentation from SockJs points out that parameters are a map that might be key, but I'm not sure which key to use here.
I have checked the url on the server that SockJs is sending and
http://http_backend/cecobrowsega-3.0.0.0.31/sockjs/testapp/620/4ydem52f/xhr?null
So in the absence of a param request, adding it null seems to be a way to send a param request!
source to share
It is available in the latest sock js client. Discussion here https://github.com/sockjs/sockjs-client/issues/72
we can pass the query string along with the connection url, the same syntax as for any HTTP call
source to share
For those who need some sample code:
var socket = new SockJS('http://localhost/ws?token=AAA');
var stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
stompClient.subscribe('/topic/echo', function(data) {
// topic handler
});
}
}, function(err) {
// connection error
});
Now all websocket related requests will have the "? Token = AAA" parameter
http: // localhost / ws / info? token = AAA & t = 1446482506843
http: // localhost / ws / 515 / z45wjz24 / websocket? token = AAA
Tested with SockJS 1.0.3
source to share