Compare commits

..

6 Commits

Author SHA1 Message Date
8c30f294bc 1.0.52 2019-06-11 03:06:18 +02:00
228eb791b7 fix(core): update 2019-06-11 03:06:17 +02:00
057476ae66 1.0.51 2019-06-10 17:46:07 +02:00
cb80e4dc2e fix(core): update 2019-06-10 17:46:06 +02:00
8410e09a4d 1.0.50 2019-06-07 11:49:10 +02:00
eb04abddbf fix(core): update 2019-06-07 11:49:10 +02:00
7 changed files with 97 additions and 17 deletions

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

14
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartuniverse",
"version": "1.0.49",
"version": "1.0.52",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -330,9 +330,9 @@
}
},
"@pushrocks/smartsocket": {
"version": "1.1.37",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsocket/-/smartsocket-1.1.37.tgz",
"integrity": "sha512-4XYj4v7yrvmh1PlKe7u6fE84bsAn4c8loGA/hxbB1IPntXBXZbXqEXnOQo6Dpqxwk6nGC4ABGpZIMXf+o6qcLQ==",
"version": "1.1.38",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsocket/-/smartsocket-1.1.38.tgz",
"integrity": "sha512-mGWEuA53GqTFOCebwo4Ayu2l7xjui7I0tdUNgZShGhIr4yv+q3sP/66q6cT388xVawIN+swviJPlPoogaoZXdA==",
"requires": {
"@pushrocks/lik": "^3.0.5",
"@pushrocks/smartdelay": "^2.0.3",
@ -510,9 +510,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "12.0.6",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.0.6.tgz",
"integrity": "sha512-3sV/MUw6uYxPaRIoooI/MjO0j1A06JNlbpkGc56F+zikO52qavehD/Qw85so47gWhO82tNzEFoF6adXqIfK+EA=="
"version": "12.0.7",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.0.7.tgz",
"integrity": "sha512-1YKeT4JitGgE4SOzyB9eMwO0nGVNkNEsm9qlIt1Lqm/tG2QEiSMTD4kS3aO6L+w5SClLVxALmIBESK6Mk5wX0A=="
},
"@types/range-parser": {
"version": "1.2.3",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartuniverse",
"version": "1.0.49",
"version": "1.0.52",
"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.9",
"@types/node": "^12.0.6",
"@types/node": "^12.0.7",
"tslint": "^5.17.0",
"tslint-config-prettier": "^1.18.0"
},
@ -33,7 +33,7 @@
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.15",
"@pushrocks/smartrx": "^2.0.3",
"@pushrocks/smartsocket": "^1.1.37",
"@pushrocks/smartsocket": "^1.1.38",
"@pushrocks/smarttime": "^3.0.7",
"@pushrocks/smartunique": "^3.0.1"
},

View File

@ -0,0 +1,4 @@
export interface IAuthenticationRequest {
channelName: string;
password: string;
}

View File

@ -95,14 +95,15 @@ export class Universe {
const SubscriptionSocketFunction = new plugins.smartsocket.SocketFunction({
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
funcName: 'channelSubscription',
funcDef: async (dataArg, socketConnectionArg) => {
funcDef: async (dataArg: interfaces.IServerCallSubscribeActionPayload, socketConnectionArg) => {
// run in "this context" of this class
(() => {
// TODO: properly add the connection
const universeConnection = new UniverseConnection({
socketConnection: socketConnectionArg,
authenticationRequests: []
})
this.universeConnectionManager.addConnection();
this.universeConnectionManager.addConnection(universeConnection);
})();
}
});

View File

@ -5,22 +5,31 @@ import { UniverseChannel } from './smartuniverse.classes.universechannel';
* represents a connection to the universe
*/
export class UniverseConnection {
public terminatedDeferred = plugins.smartpromise.defer();
/**
* the socketClient to ping
*/
public socketConnection: plugins.smartsocket.SocketConnection;
public authenticationRequests = []
public authenticationRequests = [];
public subscribedChannels: UniverseChannel[] = [];
public authenticatedChannels: UniverseChannel[] = [];
public failedToJoinChannels: UniverseChannel[] = [];
/**
* terminates the connection
*/
public terminateConnection () {
this.socketConnection
this.socketConnection.socket.disconnect();
this.terminatedDeferred.resolve();
}
constructor(optionsArg: {
socketConnection: plugins.smartsocket.SocketConnection;
authenticationRequests
}) {
this.socketConnection,
// TODO: check if this is correct
this.socketConnection.socket.disconnect();
}
}

View File

@ -7,5 +7,42 @@ import { UniverseConnection } from './smartuniverse.classes.universeconnection';
export class UniverseConnectionManager {
public connectionMap = new plugins.lik.Objectmap<UniverseConnection>();
public addConnection() {}
public async addConnection(universeConnectionArg: UniverseConnection) {
let universeConnection = universeConnectionArg;
universeConnection = await this.deduplicateUniverseConnection(universeConnection);
universeConnection = await this.authenticateAuthenticationRequests(universeConnection);
}
/**
* deduplicates UniverseConnections
*/
public async deduplicateUniverseConnection (universeConnectionArg: UniverseConnection): Promise<UniverseConnection> {
let connectionToReturn: UniverseConnection;
this.connectionMap.forEach(async existingConnection => {
if (existingConnection.socketConnection = universeConnectionArg.socketConnection) {
connectionToReturn = await this.mergeUniverseConnections(existingConnection, universeConnectionArg);
}
});
if (!connectionToReturn) {
connectionToReturn = universeConnectionArg;
}
return connectionToReturn;
}
/**
* authenticate AuthenticationRequests
*/
public authenticateAuthenticationRequests(universeConnectionArg): Promise<UniverseConnection> {
// TODO: authenticate connections
return universeConnectionArg;
}
/**
* merges two UniverseConnections
*/
public mergeUniverseConnections (connectionArg1: UniverseConnection, connectionArg2: UniverseConnection) {
// TODO: merge connections
return connectionArg1;
}
}