I've manager to reproduce one of these issues using a current build on linux.
vue native sockets in chrome browser -> Backend Espruino WS server.
If protocol is specified, then all is well:
const ws = new WebSocket('ws://192.168.1.203:8000', 'protocolOne');
However, if this is defaulted, ws.js on the espruino sends as a header:
Sec-WebSocket-Protocol: undefined
this test seems to be failing: https://github.com/espruino/EspruinoDocs/blob/master/modules/ws.js#L196-L197
if (this.protocol) socketHeader.push("Sec-WebSocket-Protocol: "+this.protocol);
in the constructor we have: https://github.com/espruino/EspruinoDocs/blob/master/modules/ws.js#L76-L86 this.protocol = options.protocol;
this.protocol = options.protocol;
So it seems this is setting this.protocol=undefined.
this.protocol=undefined
What is the cleanest way to fix?
if ( typeof(this.protocol) != 'undefined' )
@Wilberforce started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I've manager to reproduce one of these issues using a current build on linux.
vue native sockets in chrome browser -> Backend Espruino WS server.
If protocol is specified, then all is well:
const ws = new WebSocket('ws://192.168.1.203:8000', 'protocolOne');
However, if this is defaulted, ws.js on the espruino sends as a header:
Sec-WebSocket-Protocol: undefined
this test seems to be failing:
https://github.com/espruino/EspruinoDocs/blob/master/modules/ws.js#L196-L197
in the constructor we have:
https://github.com/espruino/EspruinoDocs/blob/master/modules/ws.js#L76-L86
this.protocol = options.protocol;
So it seems this is setting
this.protocol=undefined
.What is the cleanest way to fix?
if ( typeof(this.protocol) != 'undefined' )