2018-03-13 05:15:40 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const smartuniverse_classes_universemessage_1 = require("./smartuniverse.classes.universemessage");
|
|
|
|
const lik_1 = require("lik");
|
|
|
|
const smartrx_1 = require("smartrx");
|
|
|
|
class UniverseStore {
|
|
|
|
constructor(standardMessageExpiryArg) {
|
|
|
|
this.destructionTime = 60000;
|
|
|
|
this.messageStore = new lik_1.Objectmap();
|
|
|
|
this.lastId = 0; // stores the last id
|
|
|
|
this.standardMessageExpiry = standardMessageExpiryArg;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* add a message to the UniverseStore
|
|
|
|
* @param messageArg
|
|
|
|
* @param attachedPayloadArg
|
|
|
|
*/
|
|
|
|
addMessage(messageArg, attachedPayloadArg) {
|
|
|
|
this.messageStore.add(new smartuniverse_classes_universemessage_1.UniverseMessage(this, messageArg, attachedPayloadArg, this.destructionTime));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Read a message from the UniverseStore
|
|
|
|
*/
|
|
|
|
readMessagesYoungerThan(unixTimeArg) {
|
2018-03-20 07:16:54 +00:00
|
|
|
const messageObservable = smartrx_1.rxjs.Observable.from(this.messageStore.getArray()).filter(messageArg => {
|
2018-03-13 05:15:40 +00:00
|
|
|
return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime);
|
|
|
|
});
|
|
|
|
return messageObservable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.UniverseStore = UniverseStore;
|
2018-03-20 07:16:54 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGFzc2VzLnVuaXZlcnNlc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsYXNzZXMudW5pdmVyc2VzdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdz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