This commit is contained in:
Philipp Kunz 2018-03-20 08:16:54 +01:00
parent a28c96356f
commit bafa94c6ac
23 changed files with 151 additions and 67 deletions

1
dist/index.d.ts vendored
View File

@ -1,2 +1,3 @@
export * from './smartuniverse.classes.universe'; export * from './smartuniverse.classes.universe';
export * from './smartuniverse.classes.universeclient'; export * from './smartuniverse.classes.universeclient';
export * from './smartuniverse.classes.universemessage';

3
dist/index.js vendored
View File

@ -5,4 +5,5 @@ function __export(m) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smartuniverse.classes.universe")); __export(require("./smartuniverse.classes.universe"));
__export(require("./smartuniverse.classes.universeclient")); __export(require("./smartuniverse.classes.universeclient"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHNEQUFpRDtBQUNqRCw0REFBdUQifQ== __export(require("./smartuniverse.classes.universemessage"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHNEQUFpRDtBQUNqRCw0REFBdUQ7QUFDdkQsNkRBQXdEIn0=

View File

@ -10,9 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
class UniverseManager { class UniverseManager {
registerMember() { registerMember() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () { });
});
} }
} }
exports.UniverseManager = UniverseManager; exports.UniverseManager = UniverseManager;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGFzc2VzLm1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsYXNzZXMubWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBSUE7SUFFZSxjQUFjOztRQUUzQixDQUFDO0tBQUE7Q0FDRjtBQUxELDBDQUtDIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGFzc2VzLm1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsYXNzZXMubWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBSUE7SUFDZSxjQUFjOzhEQUFJLENBQUM7S0FBQTtDQUNqQztBQUZELDBDQUVDIn0=

View File

@ -17,6 +17,7 @@ export declare class Universe {
private universeVersionStore; private universeVersionStore;
private readonly universeVersion; private readonly universeVersion;
private smartexpressServer; private smartexpressServer;
private smartsocket;
constructor(optionsArg: ISmartUniverseConstructorOptions); constructor(optionsArg: ISmartUniverseConstructorOptions);
/** /**
* initiates a server * initiates a server

View File

@ -40,6 +40,11 @@ class Universe {
forceSsl: false, forceSsl: false,
port: portArg port: portArg
}); });
this.smartsocket = new plugins.smartsocket.Smartsocket({
port: 12345 // fix this within smartsocket
});
this.smartsocket.setServer(this.smartexpressServer); // should work with express as well
this.smartsocket.startServer();
// route handling // route handling
// adds messages // adds messages
const addMessageHandler = new smartexpress_1.Handler('PUT', request => { const addMessageHandler = new smartexpress_1.Handler('PUT', request => {
@ -66,4 +71,4 @@ class Universe {
} }
} }
exports.Universe = Universe; exports.Universe = Universe;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJ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QUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxPQUFPLEVBQUUsV0FBVyxDQUFDLE9BQU8sQ0FBQyxDQUFDO2dCQUN4RSxPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxDQUFDO2dCQUN6QixNQUFNLENBQUMsSUFBSSxDQUFDO1lBQ2QsQ0FBQyxDQUFDLENBQUM7WUFFSCxnQkFBZ0I7WUFDaEIsTUFBTSxrQkFBa0IsR0FBRyxJQUFJLHNCQUFPLENBQUMsS0FBSyxFQUFFLE9BQU8sQ0FBQyxFQUFFO2dCQUN0RCxNQUFNLFdBQVcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDO2dCQUNqQyxJQUFJLENBQUMsYUFBYSxDQUFDLHVCQUF1QixDQUFDLFdBQVcsQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNoRSxDQUFDLENBQUMsQ0FBQztZQUVILE1BQU0sWUFBWSxHQUFHLElBQUksb0JBQUssQ0FBQyxJQUFJLENBQUMsa0JBQWtCLEVBQUUsU0FBUyxDQUFDLENBQUM7WUFDbkUsWUFBWSxDQUFDLFVBQVUsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1lBQzNDLFlBQVksQ0FBQyxVQUFVLENBQUMsa0JBQWtCLENBQUMsQ0FBQztZQUU1QyxNQUFNLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUN4QyxDQUFDO0tBQUE7SUFFWSxVQUFVOztZQUNyQixNQUFNLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUN2QyxDQUFDO0tBQUE7Q0FDRjtBQXhFRCw0QkF3RUMifQ==

View File

@ -1,9 +1,13 @@
import * as plugins from './smartuniverse.plugins';
import { UniverseMessage } from './smartuniverse.classes.universemessage';
export interface IClientOptions { export interface IClientOptions {
serverAddress: string; serverAddress: string;
} }
export declare class UniverseClient { export declare class UniverseClient {
options: any; options: any;
private socketClient;
private observableIntake;
constructor(optionsArg: IClientOptions); constructor(optionsArg: IClientOptions);
sendMessage(messageArg: any, payloadArg: any): Promise<void>; sendMessage(messageArg: any, payloadArg: any): Promise<void>;
getMessageObservable(): void; getMessageObservable(): plugins.smartrx.rxjs.Observable<UniverseMessage>;
} }

View File

@ -9,6 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartuniverse.plugins"); const plugins = require("./smartuniverse.plugins");
const smartsocket_1 = require("smartsocket");
const url = require("url");
class UniverseClient { class UniverseClient {
constructor(optionsArg) { constructor(optionsArg) {
this.options = optionsArg; this.options = optionsArg;
@ -20,12 +22,25 @@ class UniverseClient {
payload: payloadArg payload: payloadArg
}; };
yield plugins.smartrequest.post(this.options.serverAddress, { yield plugins.smartrequest.post(this.options.serverAddress, {
requestBody: requestBody requestBody
}); });
}); });
} }
getMessageObservable() { getMessageObservable() {
if (!this.socketClient && !this.observableIntake) {
const parsedURL = url.parse(this.options.serverAddress);
this.socketClient = new smartsocket_1.SmartsocketClient({
alias: process.env.SOCKET_ALIAS || 'someclient',
password: 'UniverseClient',
port: parseInt(parsedURL.port, 10),
role: 'UniverseClient',
url: parsedURL.hostname,
});
this.observableIntake = new plugins.smartrx.ObservableIntake();
this.socketClient.connect();
}
return this.observableIntake.observable;
} }
} }
exports.UniverseClient = UniverseClient; exports.UniverseClient = UniverseClient;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGFzc2VzLnVuaXZlcnNlY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnR1bml2ZXJzZS5jbGFzc2VzLnVuaXZlcnNlY2xpZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUF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SxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLGFBQWEsRUFBRTtnQkFDMUQsV0FBVzthQUNaLENBQUMsQ0FBQztRQUNMLENBQUM7S0FBQTtJQUVNLG9CQUFvQjtRQUN6QixFQUFFLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxZQUFZLElBQUksQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO1lBQ2pELE1BQU0sU0FBUyxHQUFHLEdBQUcsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxhQUFhLENBQUMsQ0FBQztZQUN4RCxJQUFJLENBQUMsWUFBWSxHQUFHLElBQUksK0JBQWlCLENBQUM7Z0JBQ3hDLEtBQUssRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLFlBQVksSUFBSSxZQUFZO2dCQUMvQyxRQUFRLEVBQUUsZ0JBQWdCO2dCQUMxQixJQUFJLEVBQUUsUUFBUSxDQUFDLFNBQVMsQ0FBQyxJQUFJLEVBQUUsRUFBRSxDQUFDO2dCQUNsQyxJQUFJLEVBQUUsZ0JBQWdCO2dCQUN0QixHQUFHLEVBQUUsU0FBUyxDQUFDLFFBQVE7YUFDeEIsQ0FBQyxDQUFDO1lBQ0gsSUFBSSxDQUFDLGdCQUFnQixHQUFHLElBQUksT0FBTyxDQUFDLE9BQU8sQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDO1lBQy9ELElBQUksQ0FBQyxZQUFZLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDOUIsQ0FBQztRQUNELE1BQU0sQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsVUFBVSxDQUFDO0lBQzFDLENBQUM7Q0FDRjtBQWxDRCx3Q0FrQ0MifQ==

View File

@ -24,4 +24,4 @@ class UniverseMessage {
} }
} }
exports.UniverseMessage = UniverseMessage; exports.UniverseMessage = UniverseMessage;
//# sourceMappingURL=data:application/json;base64,e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VJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0dW5pdmVyc2UuY2xhc3Nlcy51bml2ZXJzZW1lc3NhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUVBLHlDQUE2QztBQUc3QztJQWNFLFlBQ0UsbUJBQWtDLEVBQ2xDLFVBQWtCLEVBQ2xCLGtCQUF1QixFQUN2QixvQkFBNEI7UUFFNUIsSUFBSSxDQUFDLGFBQWEsR0FBRyxtQkFBbUIsQ0FBQztRQUN6QyxJQUFJLENBQUMsU0FBUyxHQUFHLElBQUkscUJBQVMsRUFBRSxDQUFDO1FBQ2pDLElBQUksQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDO1FBQzFCLElBQUksQ0FBQyxlQUFlLEdBQUcsa0JBQWtCLENBQUM7UUFDMUMsSUFBSSxDQUFDLGdCQUFnQixHQUFHLElBQUksaUJBQUssQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO1FBQ3hELElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUU5Qix3RUFBd0U7UUFDeEUsSUFBSSxDQUFDLGdCQUFnQixDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsR0FBUyxFQUFFO1lBQzlDLElBQUksQ0FBQyxhQUFhLENBQUMsWUFBWSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUMvQyxDQUFDLENBQUEsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztDQUNGO0FBaENELDBDQWdDQyJ9

View File

@ -22,13 +22,11 @@ class UniverseStore {
* Read a message from the UniverseStore * Read a message from the UniverseStore
*/ */
readMessagesYoungerThan(unixTimeArg) { readMessagesYoungerThan(unixTimeArg) {
const messageObservable = smartrx_1.rxjs.Observable const messageObservable = smartrx_1.rxjs.Observable.from(this.messageStore.getArray()).filter(messageArg => {
.from(this.messageStore.getArray())
.filter(messageArg => {
return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime); return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime);
}); });
return messageObservable; return messageObservable;
} }
} }
exports.UniverseStore = UniverseStore; exports.UniverseStore = UniverseStore;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGFzc2VzLnVuaXZlcnNlc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsYXNzZXMudW5pdmVyc2VzdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLG1HQUEwRTtBQUUxRSw2QkFBK0I7QUFHL0IscUNBQThCO0FBRTlCO0lBTUUsWUFBWSx3QkFBZ0M7UUFKckMsb0JBQWUsR0FBVyxLQUFLLENBQUM7UUFDaEMsaUJBQVksR0FBRyxJQUFJLGVBQVMsRUFBbUIsQ0FBQztRQUMvQyxXQUFNLEdBQVcsQ0FBQyxDQUFDLENBQUMscUJBQXFCO1FBRy9DLElBQUksQ0FBQyxxQkFBcUIsR0FBRyx3QkFBd0IsQ0FBQztJQUN4RCxDQUFDO0lBRUQ7Ozs7T0FJRztJQUNJLFVBQVUsQ0FBQyxVQUFVLEVBQUUsa0JBQWtCO1FBQzlDLElBQUksQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDLElBQUksdURBQWUsQ0FBQyxJQUFJLEVBQUUsVUFBVSxFQUFFLGtCQUFrQixFQUFFLElBQUksQ0FBQyxlQUFlLENBQUMsQ0FBQyxDQUFDO0lBQ3pHLENBQUM7SUFFRDs7T0FFRztJQUNJLHVCQUF1QixDQUFDLFdBQW9CO1FBQ2pELE1BQU0saUJBQWlCLEdBQUcsY0FBSSxDQUFDLFVBQVU7YUFDdEMsSUFBSSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsUUFBUSxFQUFFLENBQUM7YUFDbEMsTUFB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pQixHQUFHLGNBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQyxNQUFNLENBQ2pGLFVBQVUsQ0FBQyxFQUFFO1lBQ1gsTUFBTSxDQUFDLFVBQVUsQ0FBQyxTQUFTLENBQUMseUJBQXlCLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQzlFLENBQUMsQ0FDRixDQUFDO1FBQ0YsTUFBTSxDQUFDLGlCQUFpQixDQUFDO0lBQzNCLENBQUM7Q0FDRjtBQWhDRCxzQ0FnQ0MifQ==

View File

@ -18,4 +18,4 @@ universeCli.standardTask().then((argvArg) => __awaiter(this, void 0, void 0, fun
}); });
yield standardUniverse.initServer(8765); yield standardUniverse.initServer(8765);
})); }));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsbURBQW1EO0FBRW5ELG1DQUFtQztBQUVuQyxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxNQUFNLENBQUM7QUFFekIsTUFBTSxXQUFXLEdBQUcsSUFBSSxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFDO0FBRXBELFdBQVcsQ0FBQyxZQUFZLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBTSxPQUFPLEVBQUMsRUFBRTtJQUM5QyxNQUFNLGdCQUFnQixHQUFHLElBQUksZ0JBQVEsQ0FBQztRQUNwQywyQkFBMkIsRUFBRSxLQUFLO0tBQ25DLENBQUMsQ0FBQztJQUNILE1BQU0sZ0JBQWdCLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBRTFDLENBQUMsQ0FBQSxDQUFDLENBQUMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsbURBQW1EO0FBRW5ELG1DQUFtQztBQUVuQyxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxNQUFNLENBQUM7QUFFekIsTUFBTSxXQUFXLEdBQUcsSUFBSSxPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxDQUFDO0FBRXBELFdBQVcsQ0FBQyxZQUFZLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBTSxPQUFPLEVBQUMsRUFBRTtJQUM5QyxNQUFNLGdCQUFnQixHQUFHLElBQUksZ0JBQVEsQ0FBQztRQUNwQywyQkFBMkIsRUFBRSxLQUFLO0tBQ25DLENBQUMsQ0FBQztJQUNILE1BQU0sZ0JBQWdCLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQzFDLENBQUMsQ0FBQSxDQUFDLENBQUMifQ==

View File

@ -18,4 +18,4 @@ const smartsocket = require("smartsocket");
exports.smartsocket = smartsocket; exports.smartsocket = smartsocket;
const smarttime = require("smarttime"); const smarttime = require("smarttime");
exports.smarttime = smarttime; exports.smarttime = smarttime;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnR1bml2ZXJzZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsMkJBQTJCO0FBVWxCLGtCQUFHO0FBVFosNkJBQTZCO0FBU2Ysb0JBQUk7QUFSbEIscUNBQXFDO0FBUWpCLDRCQUFRO0FBUDVCLDZDQUE2QztBQU9mLG9DQUFZO0FBTjFDLHVDQUF1QztBQU1LLDhCQUFTO0FBTHJELDZDQUE2QztBQUttQixvQ0FBWTtBQUo1RSxtQ0FBbUM7QUFJb0IsMEJBQU87QUFIOUQsMkNBQTJDO0FBR21DLGtDQUFXO0FBRnpGLHVDQUF1QztBQUVvRCw4QkFBUyJ9 //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnR1bml2ZXJzZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsMkJBQTJCO0FBV3pCLGtCQUFHO0FBVkwsNkJBQTZCO0FBVzNCLG9CQUFJO0FBVk4scUNBQXFDO0FBV25DLDRCQUFRO0FBVlYsNkNBQTZDO0FBVzNDLG9DQUFZO0FBVmQsdUNBQXVDO0FBV3JDLDhCQUFTO0FBVlgsNkNBQTZDO0FBWTNDLG9DQUFZO0FBWGQsbUNBQW1DO0FBVWpDLDBCQUFPO0FBVFQsMkNBQTJDO0FBV3pDLGtDQUFXO0FBVmIsdUNBQXVDO0FBV3JDLDhCQUFTIn0=

View File

@ -11,6 +11,7 @@
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^9.4.7",
"tapbundle": "^2.0.0" "tapbundle": "^2.0.0"
}, },
"dependencies": { "dependencies": {
@ -21,7 +22,7 @@
"smartfile": "^4.2.28", "smartfile": "^4.2.28",
"smartrequest": "^1.0.8", "smartrequest": "^1.0.8",
"smartrx": "^1.0.5", "smartrx": "^1.0.5",
"smartsocket": "^1.1.13", "smartsocket": "^1.1.16",
"smarttime": "^2.0.0" "smarttime": "^2.0.0"
} }
} }

View File

@ -2,35 +2,46 @@
import { expect, tap } from 'tapbundle'; import { expect, tap } from 'tapbundle';
import * as smartuniverse from '../ts/index'; import * as smartuniverse from '../ts/index';
import { Observable } from 'rxjs';
let testUniverse: smartuniverse.Universe; let testUniverse: smartuniverse.Universe;
let testUniverseClient: smartuniverse.UniverseClient let testUniverseClient: smartuniverse.UniverseClient;
let testMessageObservable: Observable<smartuniverse.UniverseMessage>;
tap.test('first test', async () => { tap.test('first test', async () => {
testUniverse = new smartuniverse.Universe({ testUniverse = new smartuniverse.Universe({
messageExpiryInMilliseconds: 5000 messageExpiryInMilliseconds: 1000
}); });
}); });
tap.test('add a message to the SmartUniverse', async () => { tap.test('add a message to the SmartUniverse', async () => {
await testUniverse.initServer(8765); await testUniverse.initServer(8765);
}) });
// testing message handling // testing message handling
tap.test('create smartuniverse client', async () => { tap.test('create smartuniverse client', async () => {
testUniverseClient = new smartuniverse.UniverseClient({ testUniverseClient = new smartuniverse.UniverseClient({
serverAddress: 'http://localhost:8765' serverAddress: 'http://localhost:8765'
}); });
expect(testUniverseClient).to.be.instanceof(smartuniverse.UniverseClient) expect(testUniverseClient).to.be.instanceof(smartuniverse.UniverseClient);
}) });
tap.test('should send a message correctly', async () => { tap.test('should send a message correctly', async () => {
await testUniverseClient.sendMessage('greeting', { await testUniverseClient.sendMessage('greeting', {
anyBool: true anyBool: true
}) });
}) });
tap.test('should get a obsevable correctly', async () => {
testMessageObservable = testUniverseClient.getMessageObservable();
});
tap.test('should receive a message correctly', async () => {
// TODO:
});
tap.test('should end the server correctly', async () => { tap.test('should end the server correctly', async () => {
await testUniverse.stopServer(); await testUniverse.stopServer();
}) });
tap.start(); tap.start();

View File

@ -1,2 +1,3 @@
export * from './smartuniverse.classes.universe'; export * from './smartuniverse.classes.universe';
export * from './smartuniverse.classes.universeclient'; export * from './smartuniverse.classes.universeclient';
export * from './smartuniverse.classes.universemessage';

View File

@ -3,8 +3,5 @@ import * as plugins from './smartuniverse.plugins';
import { Objectmap } from 'lik'; import { Objectmap } from 'lik';
export class UniverseManager { export class UniverseManager {
public async registerMember() {}
public async registerMember () {
}
} }

View File

@ -16,8 +16,8 @@ export interface IServerGetMessagesRequestBody {
} }
export interface IServerPutMessageRequestBody { export interface IServerPutMessageRequestBody {
message: string, message: string;
payload: any payload: any;
} }
export class Universe { export class Universe {
@ -41,12 +41,12 @@ export class Universe {
} }
private smartexpressServer: plugins.smartexpress.Server; private smartexpressServer: plugins.smartexpress.Server;
private smartsocket: plugins.smartsocket.Smartsocket;
constructor(optionsArg: ISmartUniverseConstructorOptions) { constructor(optionsArg: ISmartUniverseConstructorOptions) {
this.options = optionsArg; this.options = optionsArg;
this.universeStore = new UniverseStore(this.options.messageExpiryInMilliseconds); this.universeStore = new UniverseStore(this.options.messageExpiryInMilliseconds);
this.universeManager = new UniverseManager(); this.universeManager = new UniverseManager();
} }
/** /**
@ -60,6 +60,13 @@ export class Universe {
port: portArg port: portArg
}); });
this.smartsocket = new plugins.smartsocket.Smartsocket({
port: 12345 // fix this within smartsocket
});
this.smartsocket.setServer(this.smartexpressServer as any); // should work with express as well
this.smartsocket.startServer();
// route handling // route handling
// adds messages // adds messages
const addMessageHandler = new Handler('PUT', request => { const addMessageHandler = new Handler('PUT', request => {
@ -73,7 +80,7 @@ export class Universe {
const readMessageHandler = new Handler('GET', request => { const readMessageHandler = new Handler('GET', request => {
const requestBody = request.body; const requestBody = request.body;
this.universeStore.readMessagesYoungerThan(requestBody.since); this.universeStore.readMessagesYoungerThan(requestBody.since);
}) });
const messageRoute = new Route(this.smartexpressServer, 'message'); const messageRoute = new Route(this.smartexpressServer, 'message');
messageRoute.addHandler(addMessageHandler); messageRoute.addHandler(addMessageHandler);
@ -82,7 +89,7 @@ export class Universe {
await this.smartexpressServer.start(); await this.smartexpressServer.start();
} }
public async stopServer () { public async stopServer() {
await this.smartexpressServer.stop(); await this.smartexpressServer.stop();
} }
} }

View File

@ -1,14 +1,24 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { IServerGetMessagesRequestBody, IServerPutMessageRequestBody } from './smartuniverse.classes.universe' import { Smartsocket, SmartsocketClient } from 'smartsocket';
import * as url from 'url';
import {
IServerGetMessagesRequestBody,
IServerPutMessageRequestBody
} from './smartuniverse.classes.universe';
import { UniverseMessage } from './smartuniverse.classes.universemessage';
export interface IClientOptions { export interface IClientOptions {
serverAddress: string serverAddress: string;
} }
export class UniverseClient { export class UniverseClient {
public options; public options;
private socketClient: plugins.smartsocket.SmartsocketClient;
private observableIntake: plugins.smartrx.ObservableIntake<UniverseMessage>;
constructor(optionsArg: IClientOptions) { constructor(optionsArg: IClientOptions) {
this.options = optionsArg; this.options = optionsArg;
@ -18,13 +28,25 @@ export class UniverseClient {
const requestBody = { const requestBody = {
message: messageArg, message: messageArg,
payload: payloadArg payload: payloadArg
} };
await plugins.smartrequest.post(this.options.serverAddress, { await plugins.smartrequest.post(this.options.serverAddress, {
requestBody: requestBody requestBody
}) });
} }
public getMessageObservable () { public getMessageObservable() {
if (!this.socketClient && !this.observableIntake) {
const parsedURL = url.parse(this.options.serverAddress);
this.socketClient = new SmartsocketClient({
alias: process.env.SOCKET_ALIAS || 'someclient',
password: 'UniverseClient',
port: parseInt(parsedURL.port, 10),
role: 'UniverseClient',
url: parsedURL.hostname,
});
this.observableIntake = new plugins.smartrx.ObservableIntake();
this.socketClient.connect();
}
return this.observableIntake.observable;
} }
} }

View File

@ -17,17 +17,22 @@ export class UniverseMessage {
public attachedPayload: any; public attachedPayload: any;
public destructionTimer: Timer; public destructionTimer: Timer;
constructor(parentUniverseStore: UniverseStore, messageArg: string, attachedPayloadArg: any, selfdestructAfterArg: number) { constructor(
parentUniverseStore: UniverseStore,
messageArg: string,
attachedPayloadArg: any,
selfdestructAfterArg: number
) {
this.universeStore = parentUniverseStore; this.universeStore = parentUniverseStore;
this.timestamp = new TimeStamp(); this.timestamp = new TimeStamp();
this.message = messageArg; this.message = messageArg;
this.attachedPayload = attachedPayloadArg; this.attachedPayload = attachedPayloadArg;
this.destructionTimer = new Timer(selfdestructAfterArg) this.destructionTimer = new Timer(selfdestructAfterArg);
this.destructionTimer.start() this.destructionTimer.start();
// set up self destruction by removing this from the parent messageStore // set up self destruction by removing this from the parent messageStore
this.destructionTimer.completed.then(async () => { this.destructionTimer.completed.then(async () => {
this.universeStore.messageStore.remove(this); this.universeStore.messageStore.remove(this);
}) });
} }
} }

View File

@ -2,10 +2,10 @@ import * as plugins from './smartuniverse.plugins';
import { UniverseMessage } from './smartuniverse.classes.universemessage'; import { UniverseMessage } from './smartuniverse.classes.universemessage';
import { Objectmap } from 'lik' import { Objectmap } from 'lik';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { rxjs } from 'smartrx' import { rxjs } from 'smartrx';
export class UniverseStore { export class UniverseStore {
public standardMessageExpiry: number; public standardMessageExpiry: number;
@ -23,19 +23,20 @@ export class UniverseStore {
* @param attachedPayloadArg * @param attachedPayloadArg
*/ */
public addMessage(messageArg, attachedPayloadArg) { public addMessage(messageArg, attachedPayloadArg) {
this.messageStore.add(new UniverseMessage(this, messageArg, attachedPayloadArg, this.destructionTime)); this.messageStore.add(
new UniverseMessage(this, messageArg, attachedPayloadArg, this.destructionTime)
);
} }
/** /**
* Read a message from the UniverseStore * Read a message from the UniverseStore
*/ */
public readMessagesYoungerThan(unixTimeArg?: number): Observable<UniverseMessage> { public readMessagesYoungerThan(unixTimeArg?: number): Observable<UniverseMessage> {
const messageObservable = rxjs.Observable const messageObservable = rxjs.Observable.from(this.messageStore.getArray()).filter(
.from(this.messageStore.getArray()) messageArg => {
.filter(messageArg => {
return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime); return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime);
}); }
);
return messageObservable; return messageObservable;
} }
} }

View File

@ -11,5 +11,4 @@ universeCli.standardTask().then(async argvArg => {
messageExpiryInMilliseconds: 60000 messageExpiryInMilliseconds: 60000
}); });
await standardUniverse.initServer(8765); await standardUniverse.initServer(8765);
}); });

View File

@ -8,4 +8,14 @@ import * as smartrx from 'smartrx';
import * as smartsocket from 'smartsocket'; import * as smartsocket from 'smartsocket';
import * as smarttime from 'smarttime'; import * as smarttime from 'smarttime';
export { lik, path, smartcli, smartexpress, smartfile, smartrx, smartrequest, smartsocket, smarttime }; export {
lik,
path,
smartcli,
smartexpress,
smartfile,
smartrx,
smartrequest,
smartsocket,
smarttime
};

View File

@ -2,5 +2,11 @@
"extends": [ "extends": [
"tslint:latest", "tslint:latest",
"tslint-config-prettier" "tslint-config-prettier"
],
"rules": {
"semicolon": [
true,
"always"
] ]
}
} }

View File

@ -68,7 +68,7 @@
version "3.0.3" version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
"@types/node@*": "@types/node@*", "@types/node@^9.4.7":
version "9.4.7" version "9.4.7"
resolved "http://registry.npmjs.org/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275" resolved "http://registry.npmjs.org/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275"
@ -1427,7 +1427,7 @@ smartpath@^3.2.8:
home "^1.0.1" home "^1.0.1"
typings-global "^1.0.14" typings-global "^1.0.14"
smartq@^1.1.1, smartq@^1.1.6: smartq@^1.1.1, smartq@^1.1.6, smartq@^1.1.8:
version "1.1.8" version "1.1.8"
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.8.tgz#7e2f3b9739eb5d6c9f45f2a86e339ec81e49e8d2" resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.8.tgz#7e2f3b9739eb5d6c9f45f2a86e339ec81e49e8d2"
dependencies: dependencies:
@ -1449,9 +1449,9 @@ smartrx@^1.0.5:
smartq "^1.1.6" smartq "^1.1.6"
typings-global "^1.0.23" typings-global "^1.0.23"
smartsocket@^1.1.13: smartsocket@^1.1.16:
version "1.1.13" version "1.1.16"
resolved "https://registry.yarnpkg.com/smartsocket/-/smartsocket-1.1.13.tgz#7f9d611fa097734367139c88b1a24a95089d0ee4" resolved "https://registry.yarnpkg.com/smartsocket/-/smartsocket-1.1.16.tgz#930ffdee48ae667a810262ab4e98c30bf2d3b687"
dependencies: dependencies:
"@types/shortid" "0.0.29" "@types/shortid" "0.0.29"
"@types/socket.io" "^1.4.32" "@types/socket.io" "^1.4.32"
@ -1461,7 +1461,7 @@ smartsocket@^1.1.13:
nodehash "^1.0.4" nodehash "^1.0.4"
shortid "^2.2.8" shortid "^2.2.8"
smartdelay "^1.0.4" smartdelay "^1.0.4"
smartq "^1.1.6" smartq "^1.1.8"
socket.io "^2.0.4" socket.io "^2.0.4"
socket.io-client "^2.0.4" socket.io-client "^2.0.4"