Open XadillaX opened 4 years ago
/ping @pladaria
/ping @pladaria
@pladaria @XadillaX can we get this merged?
Having Protocols updatable would be awesome. A strong (but hackish) use case for this is sending JWT token securely when establishing connection, since the this is the only header available in the websocket browder implementation
I was this close to coding up this feature myself. I too am using protocols for sending tokens.
Sad to see this library abandoned..
Partykit looks promising!
Here is a naive workaround i was using..
export default class Socket extends ReconnectingWebSocket {
constructor(urlProvider, protocolsProvider) {
/**
* Workaround to authenticate websocket over Sec-Websocket-Protocol header
* see issue at (https://github.com/whatwg/websockets/issues/16)
* @class _WebSocket
* @extends {WebSocket}
*/
class _WebSocket extends WebSocket {
constructor(url) {
super(url, protocolsProvider())
}
}
super(urlProvider, undefined, {
WebSocket: _WebSocket,
})
}
}
In my scene,
protocol
should be updatable too. So this feature is inspired from UrlProvider.