sockjs-client icon indicating copy to clipboard operation
sockjs-client copied to clipboard

what's the usage of the param named '_reserved' when creating SockJS instance ?

Open allbutone opened this issue 8 years ago • 4 comments

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 !

allbutone avatar Apr 04 '18 05:04 allbutone

_reserved is just that. Currently not used, but reserved for future use.

Subprotocols are not supported, see #130

brycekahle avatar Apr 06 '18 17:04 brycekahle

Why couldn't the options simply be the second parameter? 😆

Edit A explicit mention of this in the README file would be appreciated.

inad9300 avatar Jun 22 '18 17:06 inad9300

@inad9300 Because the goal is to be compatible with the native Websocket constructor.

brycekahle avatar Jun 22 '18 17:06 brycekahle

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

matndev avatar Sep 10 '19 18:09 matndev