what's the usage of the param named '_reserved' when creating SockJS instance ?
sockjs client api only tells how to use the options param, but no clue on _reserved:
var sockjs = new SockJS(url, _reserved, options);
then I dig into the source code and find out that the constructor of SockJS is defined as below:
// follow constructor steps defined at http://dev.w3.org/html5/websockets/#the-websocket-interface
function SockJS(url, protocols, options) {
//....
}
so the param named "_reserved" is actually protocols which can be used for specifying sub-protocols for websocket ? when I test something like:
new SockJS(url, ['v10.stomp', 'v11.stomp']);
In Chrome and Firefox console, I didn't find the corresponding Sec-WebSocket-Protocols header. So I figured that maybe the "_reserved" param is just a placeholder for 'protocols' param, but currently SockJS do not support specifying sub-protocols like native WebSocket ?
confused now. any help is appreciated !
_reserved is just that. Currently not used, but reserved for future use.
Subprotocols are not supported, see #130
Why couldn't the options simply be the second parameter? 😆
Edit A explicit mention of this in the README file would be appreciated.
@inad9300 Because the goal is to be compatible with the native Websocket constructor.
When sub-protocols support feature will be added ? We're facing issue with Sec-Websocket-Protocol header and we can't solve anything with SockJs