Przeglądaj źródła

UNDO THIS: Trying to fix the memory leak

tags/v0.7.0^2
Shaun 4 lat temu
rodzic
commit
39a79e6969
2 zmienionych plików z 5 dodań i 22 usunięć
  1. +1
    -1
      src/server/index.js
  2. +4
    -21
      src/server/misc/events.js

+ 1
- 1
src/server/index.js Wyświetl plik

@@ -28,11 +28,11 @@ let startup = {
process.on('unhandledRejection', this.onError.bind(this));
process.on('uncaughtException', this.onError.bind(this));

animations.init();
mods.init(this.onModsLoaded.bind(this));
},

onModsLoaded: function () {
animations.init();
routerConfig.init();
classes.init();
spellsConfig.init();


+ 4
- 21
src/server/misc/events.js Wyświetl plik

@@ -1,25 +1,13 @@
module.exports = {
events: {},
queue: [],
on: function (event, callback) {
let list = this.events[event] || (this.events[event] = []);
list.push(callback);

for (let i = 0; i < this.queue.length; i++) {
let q = this.queue[i];
if (q.event !== event)
continue;

this.queue.splice(i, 1);
i--;

q.args.splice(0, 0, event);

this.emit.apply(this, q.args);
}

return callback;
},

off: function (event, callback) {
let list = this.events[event] || [];
let lLen = list.length;
@@ -34,18 +22,13 @@ module.exports = {
if (lLen === 0)
delete this.events[event];
},

emit: function (event) {
let args = [].slice.call(arguments, 1);

let list = this.events[event];
if (!list) {
this.queue.push({
event: event,
args: args
});

if (!list)
return;
}

let len = list.length;
for (let i = 0; i < len; i++) {


Ładowanie…
Anuluj
Zapisz