Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
c4261765ec | |||
33fe6bcd41 | |||
1baf1c318c | |||
051aba3299 |
155
package-lock.json
generated
155
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartuniverse",
|
||||
"version": "1.0.56",
|
||||
"version": "1.0.58",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -104,24 +104,17 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/lik": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.5.tgz",
|
||||
"integrity": "sha512-pc5Nq0WUysS34qPpyiZXiX254kL3vyRVbt3D36Q5QU+eHhxAThHofSzgOdyVHUZU2WFoaMlKowIVsyUFzIkfdw==",
|
||||
"version": "3.0.10",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.10.tgz",
|
||||
"integrity": "sha512-iWG06QsrL6AAnjPRWMVz4bRaRE0jJt/HgEK0YeLqaSBLY8ju4ps1j4lEN8VrUlXGZyPB6UGQfcreesO24buYhQ==",
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.2",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smartrx": "^2.0.3",
|
||||
"@pushrocks/smarttime": "^3.0.5",
|
||||
"@pushrocks/smarttime": "^3.0.12",
|
||||
"@types/minimatch": "^3.0.3",
|
||||
"minimatch": "^3.0.4",
|
||||
"symbol-tree": "^3.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
|
||||
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
|
||||
}
|
||||
"symbol-tree": "^3.2.4"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartcli": {
|
||||
@ -182,12 +175,12 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartexpress": {
|
||||
"version": "3.0.35",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpress/-/smartexpress-3.0.35.tgz",
|
||||
"integrity": "sha512-8DYFURxE+CXuh59O7SMRTLKaiWda/I1srcLE5Hka6YCLCahCKsT1HDVHcEVnY4E7kd9OaHEzuPa7ZddaISi5xQ==",
|
||||
"version": "3.0.38",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpress/-/smartexpress-3.0.38.tgz",
|
||||
"integrity": "sha512-di26orVJwgBRGKVpYcPrauc14CVo0piAzXTBWFZZNUCuIsndnXepd9oDzMO+KHVZpNz3W4DxbtRkppZjrh9ejw==",
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^3.0.5",
|
||||
"@pushrocks/smartfile": "^7.0.2",
|
||||
"@pushrocks/lik": "^3.0.10",
|
||||
"@pushrocks/smartfile": "^7.0.4",
|
||||
"@pushrocks/smartmanifest": "^1.0.6",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smartrequest": "^1.1.16",
|
||||
@ -199,9 +192,9 @@
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"express-force-ssl": "^0.3.2",
|
||||
"helmet": "^3.18.0",
|
||||
"helmet": "^3.20.0",
|
||||
"rendertron-middleware": "^0.1.5",
|
||||
"sitemap": "^2.2.0"
|
||||
"sitemap": "^3.2.2"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfile": {
|
||||
@ -340,14 +333,14 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartsocket": {
|
||||
"version": "1.1.38",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsocket/-/smartsocket-1.1.38.tgz",
|
||||
"integrity": "sha512-mGWEuA53GqTFOCebwo4Ayu2l7xjui7I0tdUNgZShGhIr4yv+q3sP/66q6cT388xVawIN+swviJPlPoogaoZXdA==",
|
||||
"version": "1.1.44",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsocket/-/smartsocket-1.1.44.tgz",
|
||||
"integrity": "sha512-AxDEDQw96szewxiA7Vk+ak6l7tsf2MLIThAuoV53ycDkDNXMyJizqE8fnzks9+/OEukwwas9kYNT9MyqPIS1mw==",
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^3.0.5",
|
||||
"@pushrocks/lik": "^3.0.10",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartexpress": "^3.0.21",
|
||||
"@pushrocks/smarthash": "^2.0.4",
|
||||
"@pushrocks/smartexpress": "^3.0.38",
|
||||
"@pushrocks/smarthash": "^2.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.19",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@types/shortid": "0.0.29",
|
||||
@ -525,9 +518,9 @@
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.6.8",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.6.8.tgz",
|
||||
"integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg=="
|
||||
"version": "12.7.1",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.1.tgz",
|
||||
"integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw=="
|
||||
},
|
||||
"@types/range-parser": {
|
||||
"version": "1.2.3",
|
||||
@ -604,21 +597,6 @@
|
||||
"requires": {
|
||||
"mime-types": "~2.1.24",
|
||||
"negotiator": "0.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"mime-db": {
|
||||
"version": "1.40.0",
|
||||
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz",
|
||||
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.24",
|
||||
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz",
|
||||
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
|
||||
"requires": {
|
||||
"mime-db": "1.40.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"after": {
|
||||
@ -702,9 +680,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"async-limiter": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/async-limiter/-/async-limiter-1.0.0.tgz",
|
||||
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
@ -1802,11 +1780,6 @@
|
||||
"path-exists": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.15",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash/-/lodash-4.17.15.tgz",
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
||||
},
|
||||
"lodash._baseassign": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
|
||||
@ -1856,6 +1829,11 @@
|
||||
"lodash.keys": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"lodash.chunk": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
|
||||
"integrity": "sha1-ZuXOH3btJ7QwPYxlEujRIW6BBrw="
|
||||
},
|
||||
"lodash.clonedeep": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
|
||||
@ -1881,11 +1859,21 @@
|
||||
"lodash.isarray": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"lodash.padstart": {
|
||||
"version": "4.6.1",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash.padstart/-/lodash.padstart-4.6.1.tgz",
|
||||
"integrity": "sha1-0uPuv/DZ05rVD1y9G1KnvOa7YRs="
|
||||
},
|
||||
"lodash.restparam": {
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
|
||||
"integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU="
|
||||
},
|
||||
"lodash.sortby": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://verdaccio.lossless.one/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
|
||||
"integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg="
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/log-symbols/-/log-symbols-2.2.0.tgz",
|
||||
@ -2279,9 +2267,9 @@
|
||||
}
|
||||
},
|
||||
"psl": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/psl/-/psl-1.2.0.tgz",
|
||||
"integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA=="
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://verdaccio.lossless.one/psl/-/psl-1.3.0.tgz",
|
||||
"integrity": "sha512-avHdspHO+9rQTLbv1RO+MPYeP/SzsCoxofjVnHanETfQhTJrmB0HlDoW+EiN/R+C0BZ+gERab9NY0lPN2TxNag=="
|
||||
},
|
||||
"pump": {
|
||||
"version": "3.0.0",
|
||||
@ -2535,13 +2523,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"sitemap": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/sitemap/-/sitemap-2.2.0.tgz",
|
||||
"integrity": "sha512-9Zoi3UBhSIt5jWENDRUbzsqLMJ+Fha3P2aQ2PRghmh0FOivtHsC4FAJdkAEKHvATajd74BWp/57Yh7kz/UA53Q==",
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://verdaccio.lossless.one/sitemap/-/sitemap-3.2.2.tgz",
|
||||
"integrity": "sha512-TModL/WU4m2q/mQcrDgNANn0P4LwprM9MMvG4hu5zP4c6IIKs2YLTu6nXXnNr8ODW/WFtxKggiJ1EGn2W0GNmg==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.10",
|
||||
"url-join": "^4.0.0",
|
||||
"xmlbuilder": "^10.0.0"
|
||||
"lodash.chunk": "^4.2.0",
|
||||
"lodash.padstart": "^4.6.1",
|
||||
"whatwg-url": "^7.0.0",
|
||||
"xmlbuilder": "^13.0.0"
|
||||
}
|
||||
},
|
||||
"smartchai": {
|
||||
@ -2757,9 +2746,9 @@
|
||||
}
|
||||
},
|
||||
"symbol-tree": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
||||
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="
|
||||
},
|
||||
"through2": {
|
||||
"version": "3.0.1",
|
||||
@ -2795,6 +2784,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"tr46": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/tr46/-/tr46-1.0.1.tgz",
|
||||
"integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=",
|
||||
"requires": {
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.2.0.tgz",
|
||||
@ -2909,11 +2906,6 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"url-join": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/url-join/-/url-join-4.0.1.tgz",
|
||||
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://verdaccio.lossless.one/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
@ -2978,6 +2970,21 @@
|
||||
"defaults": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://verdaccio.lossless.one/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
|
||||
"integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg=="
|
||||
},
|
||||
"whatwg-url": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/whatwg-url/-/whatwg-url-7.0.0.tgz",
|
||||
"integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==",
|
||||
"requires": {
|
||||
"lodash.sortby": "^4.7.0",
|
||||
"tr46": "^1.0.1",
|
||||
"webidl-conversions": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://verdaccio.lossless.one/which/-/which-1.3.1.tgz",
|
||||
@ -3059,9 +3066,9 @@
|
||||
"integrity": "sha512-xN0kV+8XfOQM2OPPBdEbGtbvJNNP1pvZR7sE6d44cjJFQG4OiGDdienPg5iOUGswBTiGbBvtYDURd30BMJwwqg=="
|
||||
},
|
||||
"xmlbuilder": {
|
||||
"version": "10.1.1",
|
||||
"resolved": "https://verdaccio.lossless.one/xmlbuilder/-/xmlbuilder-10.1.1.tgz",
|
||||
"integrity": "sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg=="
|
||||
"version": "13.0.2",
|
||||
"resolved": "https://verdaccio.lossless.one/xmlbuilder/-/xmlbuilder-13.0.2.tgz",
|
||||
"integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ=="
|
||||
},
|
||||
"xmlhttprequest-ssl": {
|
||||
"version": "1.5.5",
|
||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartuniverse",
|
||||
"version": "1.0.56",
|
||||
"version": "1.0.58",
|
||||
"private": false,
|
||||
"description": "messaging service for your micro services",
|
||||
"main": "dist/index.js",
|
||||
@ -17,7 +17,7 @@
|
||||
"@gitzone/tsbuild": "^2.1.11",
|
||||
"@gitzone/tstest": "^1.0.24",
|
||||
"@pushrocks/tapbundle": "^3.0.11",
|
||||
"@types/node": "^12.6.8",
|
||||
"@types/node": "^12.7.1",
|
||||
"tslint": "^5.18.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
@ -25,15 +25,15 @@
|
||||
"rxjs": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.5",
|
||||
"@pushrocks/lik": "^3.0.10",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartexpress": "^3.0.35",
|
||||
"@pushrocks/smartexpress": "^3.0.38",
|
||||
"@pushrocks/smartfile": "^7.0.4",
|
||||
"@pushrocks/smarthash": "^2.0.6",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smartrequest": "^1.1.16",
|
||||
"@pushrocks/smartrx": "^2.0.3",
|
||||
"@pushrocks/smartsocket": "^1.1.38",
|
||||
"@pushrocks/smartsocket": "^1.1.44",
|
||||
"@pushrocks/smarttime": "^3.0.12",
|
||||
"@pushrocks/smartunique": "^3.0.1"
|
||||
},
|
||||
|
@ -50,9 +50,8 @@ tap.test('should get a observable correctly', async () => {
|
||||
});
|
||||
|
||||
tap.test('should send a message correctly', async () => {
|
||||
await testClientUniverse.sendMessage({
|
||||
messageText: 'hello',
|
||||
targetChannelName: testChannelData.channelName
|
||||
await (await testClientUniverse.getChannel(testChannelData.channelName)).sendMessage({
|
||||
messageText: 'hello'
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -2,9 +2,11 @@ export interface IMessageCreator {
|
||||
messageText: string;
|
||||
payload?: string | number | any;
|
||||
payloadStringType?: 'Buffer' | 'string' | 'object';
|
||||
targetChannelName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export interface IUniverseMessage extends IMessageCreator {
|
||||
id: string;
|
||||
/**
|
||||
@ -12,4 +14,5 @@ export interface IUniverseMessage extends IMessageCreator {
|
||||
*/
|
||||
timestamp: number;
|
||||
passphrase: string;
|
||||
targetChannelName: string;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export class ClientUniverse {
|
||||
}
|
||||
|
||||
// lets create the channel
|
||||
ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg);
|
||||
await ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,21 +68,6 @@ export class ClientUniverse {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a message towards the server
|
||||
* @param messageArg
|
||||
*/
|
||||
public async sendMessage(messageArg: interfaces.IMessageCreator) {
|
||||
await this.checkConnection();
|
||||
const universeMessageToSend: interfaces.IUniverseMessage = {
|
||||
id: plugins.smartunique.shortId(),
|
||||
timestamp: Date.now(),
|
||||
passphrase: (await this.getChannel(messageArg.targetChannelName)).passphrase,
|
||||
...messageArg
|
||||
};
|
||||
await this.smartsocketClient.serverCall('processMessage', universeMessageToSend);
|
||||
}
|
||||
|
||||
public close() {
|
||||
this.smartsocketClient.disconnect();
|
||||
}
|
||||
@ -91,7 +76,7 @@ export class ClientUniverse {
|
||||
* checks the connection towards a universe server
|
||||
* since password validation is done through other means, a connection should always be possible
|
||||
*/
|
||||
private async checkConnection(): Promise<void> {
|
||||
public async checkConnection(): Promise<void> {
|
||||
if (!this.smartsocketClient && !this.observableIntake) {
|
||||
const parsedURL = url.parse(this.options.serverAddress);
|
||||
const socketConfig: plugins.smartsocket.ISmartsocketClientOptions = {
|
||||
|
@ -37,10 +37,10 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
||||
public passphrase: string;
|
||||
|
||||
// refs
|
||||
public clientUniverse: ClientUniverse;
|
||||
public clientUniverseRef: ClientUniverse;
|
||||
|
||||
constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) {
|
||||
this.clientUniverse = clientUniverseArg;
|
||||
this.clientUniverseRef = clientUniverseArg;
|
||||
this.name = nameArg;
|
||||
this.passphrase = passphraseArg;
|
||||
}
|
||||
@ -55,6 +55,24 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
||||
name: this.name,
|
||||
passphrase: this.passphrase
|
||||
};
|
||||
this.clientUniverse.smartsocketClient.serverCall(serverCallActionName, serverCallActionPayload);
|
||||
await this.clientUniverseRef.smartsocketClient.serverCall(serverCallActionName, serverCallActionPayload);
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a message towards the server
|
||||
* @param messageArg
|
||||
*/
|
||||
public async sendMessage(messageArg: interfaces.IMessageCreator) {
|
||||
await this.clientUniverseRef.checkConnection();
|
||||
const universeMessageToSend: interfaces.IUniverseMessage = {
|
||||
id: plugins.smartunique.shortId(),
|
||||
timestamp: Date.now(),
|
||||
passphrase: this.passphrase,
|
||||
targetChannelName: this.name,
|
||||
messageText: messageArg.messageText,
|
||||
payload: messageArg.payload,
|
||||
payloadStringType: messageArg.payloadStringType
|
||||
};
|
||||
await this.clientUniverseRef.smartsocketClient.serverCall('processMessage', universeMessageToSend);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export class Universe {
|
||||
// add the role to smartsocket
|
||||
this.smartsocket.addSocketRoles([ClientRole]);
|
||||
|
||||
const SubscriptionSocketFunction = new plugins.smartsocket.SocketFunction({
|
||||
const socketFunctionSubscription = new plugins.smartsocket.SocketFunction({
|
||||
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
|
||||
funcName: 'channelSubscription',
|
||||
funcDef: async (
|
||||
@ -111,7 +111,7 @@ export class Universe {
|
||||
}
|
||||
});
|
||||
|
||||
const ProcessMessageSocketFunction = new plugins.smartsocket.SocketFunction({
|
||||
const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction({
|
||||
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
|
||||
funcName: 'processMessage',
|
||||
funcDef: async (dataArg: interfaces.IUniverseMessage, socketConnectionArg) => {
|
||||
@ -124,16 +124,9 @@ export class Universe {
|
||||
if (universeConnection) {
|
||||
console.log('found UniverseConnection for socket');
|
||||
} else {
|
||||
console.log('universe client not yet present');
|
||||
console.log('creating one now as send only');
|
||||
const universeConnectionInstance = new UniverseConnection({
|
||||
socketConnection: socketConnectionArg,
|
||||
authenticationRequests: []
|
||||
});
|
||||
await UniverseConnection.addConnectionToCache(
|
||||
this.universeCache,
|
||||
universeConnectionInstance
|
||||
);
|
||||
return {
|
||||
error: 'You need to authenticate for a channel'
|
||||
};
|
||||
}
|
||||
const unauthenticatedMessage = UniverseMessage.createMessageFromPayload(dataArg);
|
||||
const foundChannel = await UniverseChannel.authorizeAMessageForAChannel(
|
||||
@ -148,6 +141,10 @@ export class Universe {
|
||||
}
|
||||
});
|
||||
|
||||
// add socket functions
|
||||
this.smartsocket.addSocketFunction(socketFunctionSubscription);
|
||||
this.smartsocket.addSocketFunction(socketFunctionProcessMessage);
|
||||
|
||||
// add smartsocket to the running smartexpress app
|
||||
this.smartsocket.setExternalServer('smartexpress', this.smartexpressServer as any);
|
||||
// start everything
|
||||
|
@ -23,6 +23,7 @@ export class UniverseConnection {
|
||||
universeConnection = await UniverseConnection.authenticateAuthenticationRequests(
|
||||
universeConnection
|
||||
);
|
||||
universeCache.connectionMap.add(universeConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user