addEventListener instead
This commit is contained in:
parent
8c2692caba
commit
1040650ae4
|
@ -27623,8 +27623,10 @@ class SocketProxy extends Module {
|
|||
socketCreated() {
|
||||
const wsHook = Global.getObject('wsHook');
|
||||
|
||||
//TODO make this better and bind other events
|
||||
const onMessageHook = setInterval(() => {
|
||||
wsHook.addEventListener('message', this.onmessage);
|
||||
|
||||
////TODO make this better and bind other events
|
||||
/* const onMessageHook = setInterval(() => {
|
||||
if (wsHook.onmessage !== null) {
|
||||
clearInterval(onMessageHook);
|
||||
//Discord sets onmessage twice so a timeout for now
|
||||
|
@ -27632,7 +27634,7 @@ class SocketProxy extends Module {
|
|||
wsHook.onmessage = Utils.overload(wsHook.onmessage, this.onmessage);
|
||||
}, 2000);
|
||||
}
|
||||
}, 100);
|
||||
}, 100);*/
|
||||
}
|
||||
|
||||
onmessage(e) {
|
||||
|
|
|
@ -27,16 +27,7 @@ class SocketProxy extends Module {
|
|||
socketCreated() {
|
||||
const wsHook = Global.getObject('wsHook');
|
||||
|
||||
//TODO make this better and bind other events
|
||||
const onMessageHook = setInterval(() => {
|
||||
if (wsHook.onmessage !== null) {
|
||||
clearInterval(onMessageHook);
|
||||
//Discord sets onmessage twice so a timeout for now
|
||||
setTimeout(() => {
|
||||
wsHook.onmessage = Utils.overload(wsHook.onmessage, this.onmessage);
|
||||
}, 2000);
|
||||
}
|
||||
}, 100);
|
||||
wsHook.addEventListener('message', this.onmessage);
|
||||
}
|
||||
|
||||
onmessage(e) {
|
||||
|
|
|
@ -35,6 +35,23 @@
|
|||
window.__bd.wsHook = this;
|
||||
}
|
||||
|
||||
/* set onmessage(fn) {
|
||||
//Don't set it
|
||||
this.__onmessage = fn;
|
||||
console.log(fn);
|
||||
console.log("Attempted to set onmessage");
|
||||
}
|
||||
|
||||
onmessage(e) {
|
||||
console.log("ON MESSAGE!!!!!!!!!!!!!!!!!!!!");
|
||||
if (this.__onmessage) this.__onmessage(e);
|
||||
}*/
|
||||
|
||||
/* onmessage(e) {
|
||||
console.log("ON MESSAGE!");
|
||||
if (this.__onmessage) this.__onmessage(e);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
window.WebSocket = WSHook;
|
||||
|
|
Loading…
Reference in New Issue