fix(core): update

This commit is contained in:
Philipp Kunz 2022-01-19 19:17:22 +01:00
parent 1e570813a3
commit acca64fa31
5 changed files with 5409 additions and 4887 deletions

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com",
"gitscope": "apiglobal",
"gitrepo": "typedsocket",
"shortDescription": "a typedrequest extension supporting websockets",
"description": "a typedrequest extension supporting websockets",
"npmPackagename": "@apiglobal/typedsocket",
"license": "MIT",
"projectDomain": "api.global"

10258
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,19 +12,19 @@
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.28",
"@gitzone/tsbuild": "^2.1.29",
"@gitzone/tsbundle": "^1.0.88",
"@gitzone/tstest": "^1.0.59",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.11.3",
"@gitzone/tstest": "^1.0.60",
"@pushrocks/tapbundle": "^3.2.15",
"@types/node": "^17.0.10",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@apiglobal/typedrequest": "^1.0.58",
"@apiglobal/typedrequest": "^1.0.65",
"@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/isohash": "^1.0.2",
"@pushrocks/smartsocket": "^1.2.8",
"@pushrocks/smartsocket": "^1.2.17",
"@pushrocks/smartstring": "^3.0.24"
},
"browserslist": [

View File

@ -3,7 +3,6 @@ import * as typedrequest from '@apiglobal/typedrequest';
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
import * as typedsocket from '../ts/index';
import { request } from 'http';
interface IRequest_Client_Server extends typedrequestInterfaces.implementsTR<
typedrequestInterfaces.ITypedRequest,
@ -42,8 +41,8 @@ tap.test('should create Server and Client', async (tools) => {
testTypedSocketServer = await typedsocket.TypedSocket.createServer(testTypedRouter);
// lets see if auto reconnect works
console.log('test: waiting 60 seconds for reconnect');
await tools.delayFor(60000);
console.log('test: waiting 21 seconds for reconnect');
await tools.delayFor(21000);
});
tap.test('should process messages from both sides', async () => {
@ -59,11 +58,7 @@ tap.test('should process messages from both sides', async () => {
console.log(response2);
})
tap.test('should run without problems for a little bit', async tools => {
await tools.delayFor(5000);
})
tap.test('should disconnect', async () => {
tap.test('should disconnect', async (tools) => {
await testTypedSocketClient.stop();
await testTypedSocketServer.stop();
})

View File

@ -16,20 +16,16 @@ export class TypedSocket {
smartexpressServerArg?: any
): Promise<TypedSocket> {
const smartsocketServer = new plugins.smartsocket.Smartsocket({
alias: 'typedsocketServer',
port: 3000,
});
if (smartexpressServerArg) {
smartsocketServer.setExternalServer('smartexpress', smartexpressServerArg);
}
const publicRole = new plugins.smartsocket.SocketRole({
name: publicRoleName,
passwordHash: await plugins.isohash.sha256FromString(publicRolePass),
});
smartsocketServer.addSocketRoles([publicRole]);
smartsocketServer.socketFunctions.add(
new plugins.smartsocket.SocketFunction({
funcName: 'processMessage',
allowedRoles: [publicRole],
funcDef: async (dataArg, socketConnectionArg) => {
return typedrouterArg.routeAndAddResponse(dataArg);
},
@ -73,10 +69,8 @@ export class TypedSocket {
): Promise<TypedSocket> {
const domain = new plugins.smartstring.Domain(serverUrlArg);
const socketOptions = {
const socketOptions: plugins.smartsocket.ISmartsocketClientOptions = {
alias: aliasArg,
role: publicRoleName,
password: publicRolePass,
port: domain.port || 3000,
url: `${domain.nodeParsedUrl.protocol}//${domain.nodeParsedUrl.hostname}`,
autoReconnect: true,
@ -87,7 +81,6 @@ export class TypedSocket {
smartsocketClient.addSocketFunction(
new plugins.smartsocket.SocketFunction({
funcName: 'processMessage',
allowedRoles: [],
funcDef: async (dataArg, socketConnectionArg) => {
return typedrouterArg.routeAndAddResponse(dataArg);
},