webhub.js
function ws_receive(raw)
{
	let data = unpack(raw); // string to byte array
	let fin = (data[0] & 128) == 128;
	let opcode = data[0] & 15;
	let isMasked = (data[1] & 128) == 128;
    let dataLength = data[1] & 127;
    let start = 2;
	let length = data.length;
	let output = "";
	
    if (dataLength == 126)
        start = 4;
    else if (dataLength == 127)
        start = 10;
        
    if (isMasked) {
		let i = start + 4;
		let masks = data.slice(start, i);
		let index = 0;
	
		while (i < length) {
			output += String.fromCharCode(data[i++] ^ masks[index++ % 4]);
		}
    } else {
		let i = start;
		while (i < length) {
			output += String.fromCharCode(data[i++]);
		}
    }

    //console.log("decode message: " + output);
    return output;
}
function ws_receive(raw)
{
	let data = unpack(raw); // string to byte array
	let fin = (data[0] & 128) == 128;
	let opcode = data[0] & 15;
	let isMasked = (data[1] & 128) == 128;
    let dataLength = data[1] & 127;
    let start = 2;
	let length = data.length;
	let output = "";
	
    if (dataLength == 126)
        start = 4;
    else if (dataLength == 127)
        start = 10;
        
    if (isMasked) {
		let i = start + 4;
		let masks = data.slice(start, i);
		let index = 0;
	
		while (i < length) {
			output += String.fromCharCode(data[i++] ^ masks[index++ % 4]);
		}
    } else {
		let i = start;
		while (i < length) {
			output += String.fromCharCode(data[i++]);
		}
    }

    //console.log("decode message: " + output);
    return output;
}
function ws_receive ( raw ) { let data = unpack ( raw ) ; // string to byte array let fin = ( data [ 0 ] & 128 ) == 128 ; let opcode = data [ 0 ] & 15 ; let isMasked = ( data [ 1 ] & 128 ) == 128 ; let dataLength = data [ 1 ] & 127 ; let start = 2 ; let length = data . length ; let output = "" ; if ( dataLength == 126 ) start = 4 ; else if ( dataLength == 127 ) start = 10 ; if ( isMasked ) { let i = start + 4 ; let masks = data . slice ( start , i ) ; let index = 0 ; while ( i < length ) { output += String . fromCharCode ( data [ i ++ ] ^ masks [ index ++ % 4 ] ) ; } } else { let i = start ; while ( i < length ) { output += String . fromCharCode ( data [ i ++ ] ) ; } } //console.log("decode message: " + output); return output ; }
return message as string
return message as string