Compare commits

..

9 Commits

Author SHA1 Message Date
1e570813a3 1.0.21 2021-11-10 17:35:55 +01:00
0199e8ef17 fix(core): update 2021-11-10 17:35:55 +01:00
68def29c80 1.0.20 2021-10-23 00:27:47 +02:00
106eb12a7f fix(core): update 2021-10-23 00:27:46 +02:00
5b868f1259 1.0.19 2021-10-22 21:09:43 +02:00
952835e46a fix(core): update 2021-10-22 21:09:42 +02:00
5aa8048ce8 1.0.18 2021-07-20 11:09:23 +02:00
48112f97ce fix(core): update 2021-07-20 11:09:22 +02:00
57a10080b5 1.0.17 2021-07-20 02:44:14 +02:00
5 changed files with 1763 additions and 1917 deletions

View File

@@ -36,6 +36,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

3635
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@apiglobal/typedsocket",
"version": "1.0.16",
"version": "1.0.21",
"private": false,
"description": "a typedrequest extension supporting websockets",
"main": "dist_ts/index.js",
@@ -12,19 +12,18 @@
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.80",
"@gitzone/tstest": "^1.0.54",
"@gitzone/tsbuild": "^2.1.28",
"@gitzone/tsbundle": "^1.0.88",
"@gitzone/tstest": "^1.0.59",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.3.3",
"@types/node": "^16.11.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@apiglobal/typedrequest": "^1.0.56",
"@apiglobal/typedrequest": "^1.0.58",
"@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/isohash": "^1.0.2",
"@pushrocks/smartexpress": "^3.0.102",
"@pushrocks/smartsocket": "^1.2.8",
"@pushrocks/smartstring": "^3.0.24"
},

View File

@@ -34,9 +34,15 @@ tap.test('should add some handlers', async () => {
tap.test('should create Server and Client', async (tools) => {
testTypedSocketServer = await typedsocket.TypedSocket.createServer(testTypedRouter);
testTypedSocketClient = await typedsocket.TypedSocket.createClient(testTypedRouter, 'http://localhost:3000');
await tools.delayFor(1000);
console.log('test: waiting 5 seconds');
await tools.delayFor(5000);
await testTypedSocketServer.stop();
// lets create another server
testTypedSocketServer = await typedsocket.TypedSocket.createServer(testTypedRouter);
// lets see if auto reconnect works
console.log('test: waiting 60 seconds for reconnect');
await tools.delayFor(60000);
});

View File

@@ -1,5 +1,4 @@
import * as plugins from './typedsocket.plugins';
import type * as smartexpress from '@pushrocks/smartexpress';
const publicRoleName = 'publicRoleName';
const publicRolePass = 'publicRolePass';
@@ -14,7 +13,7 @@ export class TypedSocket {
*/
public static async createServer(
typedrouterArg: plugins.typedrequest.TypedRouter,
smartexpressServerArg?: smartexpress.Server
smartexpressServerArg?: any
): Promise<TypedSocket> {
const smartsocketServer = new plugins.smartsocket.Smartsocket({
port: 3000,
@@ -50,7 +49,7 @@ export class TypedSocket {
);
targetConnectionArg = smartsocketServer.socketConnections.getArray()[0];
} else {
throw new Error('you need to specify the wanted targetConnection');
throw new Error('you need to specify the wanted targetConnection. Currently no target is selectable automatically.');
}
}
const response: T = await smartsocketServer.clientCall(
@@ -157,6 +156,11 @@ export class TypedSocket {
return typedrequest;
}
/**
* returns all matching target connection
* @param asyncFindFuncArg
* @returns
*/
public async findAllTargetConnections(
asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
) {
@@ -173,10 +177,15 @@ export class TypedSocket {
}
}
/**
* returns a single target connection by returning the first one of all matching ones
* @param asyncFindFuncArg
* @returns
*/
public async findTargetConnection(
asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
) {
const allMatching = this.findAllTargetConnections(asyncFindFuncArg);
const allMatching = await this.findAllTargetConnections(asyncFindFuncArg);
return allMatching[0];
}
@@ -184,16 +193,16 @@ export class TypedSocket {
return this.findAllTargetConnections(async socketConnectionArg => {
let result: boolean;
if (!payloadArg) {
result = !!socketConnectionArg.getTagById('keyArg')
result = !!socketConnectionArg.getTagById(keyArg);
} else {
result = !!socketConnectionArg.getTagById('keyArg') === payloadArg;
result = !!socketConnectionArg.getTagById(keyArg) === payloadArg;
}
return result;
})
}
public async findTargetConnectionByTag(keyArg: string, payloadArg?: any) {
const allResults = this.findAllTargetConnectionsByTag(keyArg, payloadArg)
const allResults = await this.findAllTargetConnectionsByTag(keyArg, payloadArg)
return allResults[0];
}