This commit is contained in:
Emily 2019-08-01 19:02:47 +02:00
parent c9350aa8db
commit 9c2cbb1921

View File

@ -1,7 +1,7 @@
class FLYSocket {
constructor(ws,
callbackData = this.callbackDummy,
callbackRaw = this.callbackDummy) {
callbackData = null,
callbackRaw = null) {
this.ws = new WebSocket(ws);
this.pointer = 0;
@ -15,11 +15,10 @@ class FLYSocket {
new Response(event.data).arrayBuffer().then(
function(buff) {
let data = new DataView(buff);
this.callbackRaw(data);
if (this.callbackData != this.callbackDummy) {
if (this.callbackRaw !== null)
this.callbackRaw(data);
if (this.callbackData !== null)
this.callbackData( this.parse(data) );
}
}.bind(this)
);
}
@ -186,11 +185,7 @@ class FLYSocket {
*buffer2HexArray(buff, start = 0, end = buff.byteLength) {
for (let i = start; i < end; i++) {
yield hex.push( buff.getUint8(i).toString(16) );
yield buff.getUint8(i).toString(16);
}
}
callbackDummy(_) {}
}
console.log("OK") // TODO: please remove...
}