Add comments
This commit is contained in:
parent
348003e4d6
commit
521bce612a
|
@ -1,17 +1,24 @@
|
|||
//Blink hack mod that prototype pollutes WebSocket to implement itself.
|
||||
|
||||
//Blinking state
|
||||
var blinking = false;
|
||||
|
||||
//The backlog of packets that need to be sent on disable
|
||||
var backlog = [];
|
||||
|
||||
//Store the original, actual WebSocket send method
|
||||
const originalSend = WebSocket.prototype.send;
|
||||
|
||||
//Override WebSocket.send, so when eagler tries to send messages, it runs our code instead
|
||||
Object.defineProperty(WebSocket.prototype, 'send', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: function(data) {
|
||||
//If blinking, push data to backlog along with it's websocket instance.
|
||||
if (blinking) {
|
||||
backlog.push({data: data, thisArg: this});
|
||||
} else {
|
||||
} else { //Else send the data as normal
|
||||
originalSend.call(this, data);
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +26,11 @@ Object.defineProperty(WebSocket.prototype, 'send', {
|
|||
|
||||
|
||||
ModAPI.addEventListener("key", (ev)=>{
|
||||
if (ev.key === 48) {
|
||||
if (ev.key === 48) { //KEY_B
|
||||
ev.preventDefault = true;
|
||||
blinking = !blinking;
|
||||
if (blinking === false) {
|
||||
blinking = !blinking; //Toggle blinking boolean
|
||||
|
||||
if (blinking === false) { //If blink just turned off, send data.
|
||||
for (let i = 0; i < backlog.length; i++) {
|
||||
const backlogItem = backlog[i];
|
||||
originalSend.call(backlogItem.thisArg, backlogItem.data);
|
||||
|
|
Loading…
Reference in New Issue