fix(core): update
This commit is contained in:
@ -178,6 +178,7 @@ export class Universe {
|
||||
* stop everything
|
||||
*/
|
||||
public async stopServer() {
|
||||
console.log('hi');
|
||||
await this.smartsocket.stop();
|
||||
if (!this.options.externalServer) {
|
||||
await this.smartexpressServer.stop();
|
||||
|
@ -19,7 +19,7 @@ export class UniverseCache {
|
||||
// INSTANCE
|
||||
// ========
|
||||
public standardMessageExpiry: number;
|
||||
public destructionTime: number = 60000;
|
||||
public destructionTime: number = 10000;
|
||||
|
||||
/**
|
||||
* stores messages for this instance
|
||||
|
@ -163,6 +163,6 @@ export class UniverseChannel {
|
||||
passphrase: this.passphrase,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
this.push(messageToSend);
|
||||
this.universeRef.universeCache.addMessage(messageToSend);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
|
||||
this.passphrase = messageDescriptor.passphrase;
|
||||
this.payload = messageDescriptor.payload;
|
||||
// prevent memory issues
|
||||
this.fallBackDestruction();
|
||||
this.setDestructionTimer();
|
||||
}
|
||||
|
||||
public setUniverseCache(universeCacheArg: UniverseCache) {
|
||||
@ -73,17 +73,23 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
|
||||
|
||||
public setTargetChannel() {}
|
||||
|
||||
public setDestructionTimer(selfdestructAfterArg: number) {
|
||||
public setDestructionTimer(selfdestructAfterArg?: number) {
|
||||
if (selfdestructAfterArg) {
|
||||
this.destructionTimer = new Timer(selfdestructAfterArg);
|
||||
this.destructionTimer.start();
|
||||
|
||||
// set up self destruction by removing this from the parent messageCache
|
||||
this.destructionTimer.completed.then(async () => {
|
||||
this.universeCache.messageMap.remove(this);
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
console.log(this);
|
||||
});
|
||||
} else {
|
||||
this.fallBackDestruction();
|
||||
plugins.smartdelay.delayFor(1000).then(() => {
|
||||
if (!this.destructionTimer) {
|
||||
this.setDestructionTimer(6000);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,15 +99,4 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
|
||||
public handleAsBadMessage() {
|
||||
plugins.smartlog.defaultLogger.log('warn', 'received a bad message');
|
||||
}
|
||||
|
||||
/**
|
||||
* prevents memory leaks if channels have no default
|
||||
*/
|
||||
private fallBackDestruction() {
|
||||
plugins.smartdelay.delayFor(1000).then(() => {
|
||||
if (!this.destructionTimer) {
|
||||
this.setDestructionTimer(6000);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user