From 10860650008cc779827e331ec3d28ced8e49f3cd Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 29 Sep 2020 18:58:09 +0000 Subject: [PATCH] fix(core): update --- package-lock.json | 6 +++--- package.json | 2 +- ts/smartsocket.classes.smartsocketclient.ts | 12 ++++++++++-- ts/smartsocket.plugins.ts | 7 ------- ts/smartsocket.pluginstyped.ts | 12 ++++-------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2acd803..342b7a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1560,9 +1560,9 @@ } }, "@pushrocks/smartenv": { - "version": "4.0.11", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartenv/-/smartenv-4.0.11.tgz", - "integrity": "sha512-dmphN7A3sUBdoBYbWdIYRvNEhvsZSZn/57tSMlpgqcyfGixYC8PGXKvqbsBKLnEwfpBFVQD95hHe26srANqELA==", + "version": "4.0.13", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartenv/-/smartenv-4.0.13.tgz", + "integrity": "sha512-6H9bBRrU8lKzIw2G+Cu6gUzIw2Gn/oYHY6gzxAzsozcUQG6tKKM5tU+A12FgVgOiVDDoki+h8LfDu2D85wqq8A==", "requires": { "@pushrocks/smartparam": "^1.1.6", "@pushrocks/smartpromise": "^3.0.6", diff --git a/package.json b/package.json index d39496d..ed1582a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@pushrocks/isounique": "^1.0.4", "@pushrocks/lik": "^4.0.17", "@pushrocks/smartdelay": "^2.0.10", - "@pushrocks/smartenv": "^4.0.11", + "@pushrocks/smartenv": "^4.0.13", "@pushrocks/smartexpress": "^3.0.76", "@pushrocks/smartlog": "^2.0.39", "@pushrocks/smartpromise": "^3.0.6", diff --git a/ts/smartsocket.classes.smartsocketclient.ts b/ts/smartsocket.classes.smartsocketclient.ts index 4f2ab7b..5017b4d 100644 --- a/ts/smartsocket.classes.smartsocketclient.ts +++ b/ts/smartsocket.classes.smartsocketclient.ts @@ -64,8 +64,16 @@ export class SmartsocketClient { /** * connect the client to the server */ - public connect() { + public async connect() { const done = plugins.smartpromise.defer(); + const smartenvInstance = new plugins.smartenv.Smartenv(); + const socketIoClient = await smartenvInstance.getEnvAwareModule({ + nodeModuleName: 'socket.io-client', + webUrlArg: 'https://cdn.jsdelivr.net/npm/socket.io-client@2/dist/socket.io.js', + getFunction: () => { + return globalThis.io; + } + }); logger.log('info', 'trying to connect...'); const socketUrl = `${this.serverUrl}:${this.serverPort}`; this.socketConnection = new SocketConnection({ @@ -74,7 +82,7 @@ export class SmartsocketClient { role: this.socketRole, side: 'client', smartsocketHost: this, - socket: plugins.socketIoClient(socketUrl, { + socket: await socketIoClient.connect(socketUrl, { multiplex: false, reconnectionAttempts: 5, }), diff --git a/ts/smartsocket.plugins.ts b/ts/smartsocket.plugins.ts index f5e58da..d829717 100644 --- a/ts/smartsocket.plugins.ts +++ b/ts/smartsocket.plugins.ts @@ -25,10 +25,3 @@ export { smarttime, smartrx, }; - -// third party -import socketIoClient from 'socket.io-client'; - -export { - socketIoClient -}; diff --git a/ts/smartsocket.pluginstyped.ts b/ts/smartsocket.pluginstyped.ts index 0b40aa7..79ca4f2 100644 --- a/ts/smartsocket.pluginstyped.ts +++ b/ts/smartsocket.pluginstyped.ts @@ -2,19 +2,15 @@ import type http from 'http'; import type https from 'https'; -export { - http, - https -}; +export { http, https }; // pushrocks scope import type * as smartexpress from '@pushrocks/smartexpress'; -export { - smartexpress -}; +export { smartexpress }; // third party scope import type socketIo from 'socket.io'; +import type socketIoClient from 'socket.io-client'; -export { socketIo }; +export { socketIo, socketIoClient };