diff --git a/documentation/english_documentation.md b/documentation/english_documentation.md index d86f07f..9e1913b 100644 --- a/documentation/english_documentation.md +++ b/documentation/english_documentation.md @@ -67,7 +67,7 @@ ##### `useDefaultLogger?:boolean` - If `true`: the default logger will be used (optional). + If `true`: the default logger will be used (optional). Set to `false` on a production environment. Default: `false` Example: server.init({ @@ -78,7 +78,7 @@ ##### `customLogger` - Allows the implementation of a custom logger (optional). + Allows the implementation of a custom logger (optional). Let it `null` on a production environment Type: `(message, level, additionalData?) => void` diff --git a/documentation/portugues_documentacao.md b/documentation/portugues_documentacao.md index 9295c22..8afdb96 100644 --- a/documentation/portugues_documentacao.md +++ b/documentation/portugues_documentacao.md @@ -70,7 +70,7 @@ Consiste em um objeto que pode conter os campos: ##### `useDefaultLogger?:boolean` - Se `true`: o logger padrão será utilizado (opcional). + Se `true`: o logger padrão será utilizado (opcional). Defina como `false` em um ambiente de produção. Padrão: `false` Exemplo: server.init({ @@ -81,7 +81,7 @@ Consiste em um objeto que pode conter os campos: ##### `customLogger` - Permite criar a própria implementação do logger (opcional). + Permite criar a própria implementação do logger (opcional). Deixe `null` em um ambiente de produção Tipo: `(message, level, additionalData?) => void` diff --git a/example/catalog-js/index.js b/example/catalog-js/index.js index 781e9a2..8eb9cce 100644 --- a/example/catalog-js/index.js +++ b/example/catalog-js/index.js @@ -44,3 +44,4 @@ server.addRoute([ server.start(); +console.log('my local server url: '+server.localUrl); diff --git a/example/catalog-ts/index.ts b/example/catalog-ts/index.ts index 699346a..1bb06b9 100644 --- a/example/catalog-ts/index.ts +++ b/example/catalog-ts/index.ts @@ -34,3 +34,4 @@ server.addRoute([ server.start(); +console.log('my local server url: '+server.localUrl); diff --git a/example/chat-js/index.js b/example/chat-js/index.js index 7c2cc4a..20a4c07 100644 --- a/example/chat-js/index.js +++ b/example/chat-js/index.js @@ -76,3 +76,5 @@ server.addCreateRoute({ }); server.start(); + +console.log('my local server url: '+server.localUrl); diff --git a/example/tracking-ts/index.ts b/example/tracking-ts/index.ts index c0a19c3..2d9a878 100644 --- a/example/tracking-ts/index.ts +++ b/example/tracking-ts/index.ts @@ -16,7 +16,7 @@ server.addReadRoute({ route: 'product/tracking-ts', read: async (context) => { context.respondSuccess({ - output: trackingStatus + output: 'addReadRoute response: \"'+trackingStatus+"\"" }); }, }); @@ -39,7 +39,7 @@ server.addCreateRoute({ server.start(); -let kmRemaining = 1000000; +let kmRemaining = 800; const kmRemainingTask = setInterval(() => { if(kmRemaining == 0){ return clearInterval(kmRemainingTask); @@ -50,4 +50,6 @@ const kmRemainingTask = setInterval(() => { server.notifyClients('product/tracking-ts', { output: trackingStatus }); -}, 1 * 1000); +}, 2500); + +console.log('my local server url: '+server.localUrl); diff --git a/package.json b/package.json index ccf1399..876ed93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "askless", - "version": "1.0.0", + "version": "1.1.0", "description": "Framework that facilitates building servers for JavaScript and Flutter Apps", "keywords": [ "flutter", diff --git a/src/client_middleware/ClientMiddleware.ts b/src/client_middleware/ClientMiddleware.ts index c40842d..23a0b6b 100644 --- a/src/client_middleware/ClientMiddleware.ts +++ b/src/client_middleware/ClientMiddleware.ts @@ -35,10 +35,7 @@ export class ClientMiddleware { start() { const self = this; this.server4Flutter.wss.on("connection", (ws) => { - self.server4Flutter.logger( - 'new client connected, sending "welcome"', - "debug" - ); + self.server4Flutter.logger('new client connected, sending "welcome"', "debug"); ws.send("welcome"); @@ -118,20 +115,12 @@ export class ClientMiddleware { ws.on("error", function (_, err) { // _ is websocket, but it doesn't have the clientId field - self.server4Flutter.logger( - "websocket error: " + ws + " " + err.toString(), - "error", - {err} - ); + self.server4Flutter.logger("websocket error: " + ws + " " + err.toString(), "error", {err}); }); ws.on("close", function (_, code, reason) { // _ is websocket, but it doesn't have the clientId field - self.server4Flutter.logger( - "websocket close: " + ws + " " + JSON.stringify(code) + " " + JSON.stringify(reason), - "debug", - code - ); + self.server4Flutter.logger("websocket close: " + ws + " " + JSON.stringify(code) + " " + JSON.stringify(reason), "debug", code); self.clients.getClientInfo(ws[ws_clientId])?.onClose?.(); }); }); @@ -178,25 +167,14 @@ export class ClientMiddleware { onClientFailsToReceive: onClientFailsToReceive, }); - this.server4Flutter.logger( - "Sending message to client", - "debug", - sendData - ); + this.server4Flutter.logger("Sending message to client", "debug", sendData); if (clientInfo.sendMessage) clientInfo.sendMessage(JSON.stringify(sendData)); else - this.server4Flutter.logger( - "Message not sent, waiting the client connect again...", - "debug", - sendData - ); + this.server4Flutter.logger("Message not sent, waiting the client connect again...", "debug", sendData); } catch (e) { - this.server4Flutter.logger("assertSendDataToClient error", "error", { - stack: e.stack, - sendData, - }); + this.server4Flutter.logger("assertSendDataToClient error", "error", {stack: e.stack, sendData,}); } } } diff --git a/src/client_middleware/ReceiveMessageHandler.ts b/src/client_middleware/ReceiveMessageHandler.ts index de74973..8f09bc5 100644 --- a/src/client_middleware/ReceiveMessageHandler.ts +++ b/src/client_middleware/ReceiveMessageHandler.ts @@ -59,12 +59,7 @@ export class ReceiveMessageHandler { if (ws) { ws.send(message); } else { - this.internalServerImp.logger( - "ClientMiddleware: ws null: the client " + - ws[ws_clientId] + - " is not connected anymore", - "error" - ); + this.internalServerImp.logger("ClientMiddleware: ws null: the client " + ws[ws_clientId] + " is not connected anymore", "error"); } } catch (e) { this.internalServerImp.logger("ClientMiddleware", "error", e); @@ -72,10 +67,7 @@ export class ReceiveMessageHandler { }; clientInfo.onClose = () => { - this.internalServerImp.logger( - "onClose websocket " + ws[ws_clientId], - "debug" - ); + this.internalServerImp.logger("onClose websocket " + ws[ws_clientId], "debug"); //Apaga apenas as informações relacionadas a conexão, não apaga mensagens pendentes //As respostas serão deixadas ainda, serão apagadas depois com o clientId_disconnectedAt clientInfo.sendMessage = null; @@ -84,10 +76,7 @@ export class ReceiveMessageHandler { clientInfo.disconnectedAt = Date.now(); }; clientInfo.doWsDisconnect = () => { - this.internalServerImp.logger( - "doWsDisconnect " + ws[ws_clientId], - "debug" - ); + this.internalServerImp.logger("doWsDisconnect " + ws[ws_clientId], "debug"); ws.close(); }; @@ -114,10 +103,7 @@ export class ReceiveMessageHandler { ownClientIdOrNull = Utils.getOwnClientId(ws[ws_clientId]); if (ws[ws_clientId] == null) { //clientId = _input['clientId']; - this.internalServerImp.logger( - "clientId is undefined: " + JSON.stringify(_input), - "debug" - ); + this.internalServerImp.logger("clientId is undefined: " + JSON.stringify(_input), "debug"); return; } const clientInfo = this.internalServerImp.clientMiddleware.clients.getClientInfo(ws[ws_clientId]); @@ -130,11 +116,7 @@ export class ReceiveMessageHandler { _input[ConfigureConnectionRequestCli.type] == null ) { //Is not possible to execute any operation BEFORE setting the headers - this.internalServerImp.logger( - "Is not possible to execute any operation BEFORE setting the headers", - "error", - _input - ); + this.internalServerImp.logger("Is not possible to execute any operation BEFORE setting the headers", "error", _input); return; } @@ -152,13 +134,7 @@ export class ReceiveMessageHandler { (c: LastClientRequest) => c.clientRequestId == _input.clientRequestId ); if (requestAlreadyReceivedFromClientBefore) { - this.internalServerImp.logger( - "handleClientRequestInput: request already receipt: " + - _input.clientRequestId + - " from clientId=" + - ws[ws_clientId], - "debug" - ); + this.internalServerImp.logger("handleClientRequestInput: request already receipt: " + _input.clientRequestId + " from clientId=" + ws[ws_clientId], "debug"); requestAlreadyReceivedFromClientBefore.requestReceivedAt = Date.now(); return; } @@ -168,14 +144,7 @@ export class ReceiveMessageHandler { const NOW = Date.now(); if (clientInfo.lastClientRequestList.length > 100) { - this.internalServerImp.logger( - "handleClientRequestInput: Start of removing unnecessary info's of user " + - clientInfo.clientId + - "... (" + - clientInfo.lastClientRequestList.length + - ")", - "debug" - ); + this.internalServerImp.logger("handleClientRequestInput: Start of removing unnecessary info's of user " + clientInfo.clientId + "... (" + clientInfo.lastClientRequestList.length + ")", "debug"); const remove = Array(); for ( let i = clientInfo.lastClientRequestList.length - 1; @@ -193,14 +162,7 @@ export class ReceiveMessageHandler { clientInfo.lastClientRequestList = clientInfo.lastClientRequestList.filter( (req) => req && !remove.includes(req) ); - this.internalServerImp.logger( - "handleClientRequestInput: End of removing unnecessary info's of user " + - clientInfo.clientId + - "... (" + - clientInfo.lastClientRequestList.length + - ")", - "debug" - ); + this.internalServerImp.logger("handleClientRequestInput: End of removing unnecessary info's of user " + clientInfo.clientId + "... (" + clientInfo.lastClientRequestList.length + ")", "debug"); } // console.log('-------------- INPUT ---------------'); @@ -255,14 +217,7 @@ export class ReceiveMessageHandler { if (response instanceof RespondError) { if (response.code == null) - this.internalServerImp.logger( - "respondWithError: read in " + - data.route + - "/" + - data.route + - " is null", - "warning" - ); + this.internalServerImp.logger("respondWithError: read in " + data.route + "/" + data.route + " is null", "warning"); service.server4Flutter.clientMiddleware.assertSendDataToClient( clientId, new ResponseCli(data.clientRequestId, null, response), @@ -273,14 +228,7 @@ export class ReceiveMessageHandler { } else { response = response as RespondSuccess; if (response == null || response.output == null) - this.internalServerImp.logger( - "respondWithSuccess: read in " + - data.route + - "/" + - data.route + - " is null", - "warning" - ); + this.internalServerImp.logger("respondWithSuccess: read in " + data.route + "/" + data.route + " is null", "warning"); service.server4Flutter.clientMiddleware.assertSendDataToClient( clientId, new ResponseCli(data.clientRequestId, response?.output), @@ -418,10 +366,7 @@ export class ReceiveMessageHandler { if (clientInfoServer.sendMessage != null) clientInfoServer.sendMessage("pong"); else - this.internalServerImp.logger( - 'handlePingFromClient: Could not send the "pong" to client', - "error" - ); + this.internalServerImp.logger('handlePingFromClient: Could not send the "pong" to client', "error"); const routesThatClientDoesntListenAnymoreAndCanBeRemovedFromServer = clientInfoServer.routesBeingListen.filter( (routeBeingListen) => { diff --git a/src/environment.ts b/src/environment.ts index e68204d..288413b 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -1,52 +1,16 @@ - - -//TODO onupdate client: -//TODO onupdate server: export const environment = { - flutterClient: { - versions: [ - { - name: "1.0.0", - code: 1, - }, - { - name: "1.0.1", - code: 2, - }, - //TODO onupdate - ], - current: 2, //TODO onupdate - }, - webClient: { - versions: [ - { - name: "1.0.0", - code: 1, - }, - //TODO onupdate - ], - current: 1, //TODO onupdate - }, - server: { - versions: [ - { - name: "1.0.0", - code: 1, - clientVersionCodeSupported: { - flutter: { - moreThanOrEqual: null, - lessThanOrEqual: null, - }, - web: { - moreThanOrEqual: null, - lessThanOrEqual: null, - }, - } + name: "1.1.0", //TODO onupdate: change package.json as well + code: 2, + clientVersionCodeSupported: { + flutter: { + moreThanOrEqual: null, + lessThanOrEqual: null, + }, + javascript: { + moreThanOrEqual: null, + lessThanOrEqual: null, }, - ], - //TODO onupdate client: - //TODO onupdate server: - current: "1.0.0", - }, -}; + } + } +} diff --git a/src/index.ts b/src/index.ts index 431dcff..9e4e618 100644 --- a/src/index.ts +++ b/src/index.ts @@ -109,12 +109,11 @@ export interface IServerConfiguration { * * `useDefaultLogger?:boolean` * - * If `true`: the default logger will be used (optional). - * Default: true + * If `true`: the default logger will be used (optional). Set to `false` on a production environment. Default: `false` * * customLogger * - * Allows the implementation of a custom logger (optional). + * Allows the implementation of a custom logger (optional). Let it `null` on a production environment * * Type: `(message, level, additionalData?) => void` * @@ -138,30 +137,30 @@ export interface IServerConfiguration { ///showAllLogs?:boolean, /** - * Allows the implementation of a custom logger (optional). + * If `true`: the default logger will be used (optional). Set to `false` on a production environment. Default: `false`
* * @example * server.init({ * logger: { - * useDefaultLogger: true + * customLogger: (message, level, additionalData?: Object) => { + * console.log(level+ ": "+message); + * if(additionalData) + * console.log(JSON.stringify(additionalData)); + * }; * }, * }); * * */ useDefaultLogger?: boolean; + /** - * If `true`: the default logger will be used (optional).
- * Default: true
+ * Allows the implementation of a custom logger (optional). Let it `null` on a production environment * * @example * server.init({ * logger: { - * customLogger: (message, level, additionalData?: Object) => { - * console.log(level+ ": "+message); - * if(additionalData) - * console.log(JSON.stringify(additionalData)); - * }; + * useDefaultLogger: true * }, * }); * @@ -277,7 +276,7 @@ export class ServerInternalImp { }; this._logger = (message, level, additionalData?: Object) => { - if (config.logger?.useDefaultLogger || (!config.logger?.customLogger && config.logger?.useDefaultLogger==null)) { + if (config.logger?.useDefaultLogger) { console.log(level + ": " + message); if (additionalData) console.log(JSON.stringify(additionalData)); @@ -286,6 +285,22 @@ export class ServerInternalImp { config.logger.customLogger(message, level, additionalData); } }; + if(config.logger?.useDefaultLogger){ + this._logger('\n'+ + '****************************************************************************************\n' + + '** WARNING: useDefaultLogger is \'true\', SET it to \'false\' on a production environment **\n' + + '****************************************************************************************', + "warning" + ); + } + if(config.logger?.customLogger){ + this._logger( '\n' + + '*************************************************************************************************************************\n' + + '** WARNING: You are using a customLogger, data content can appear on the logs (logs with \'debug\' level shows it a lot) **\n' + + '*************************************************************************************************************************', + "warning" + ); + } } init(config: IServerConfiguration) { @@ -305,6 +320,10 @@ export class ServerInternalImp { return this._logger(message, level, additionalData); } + get localUrl () : String { + return 'ws://'+myIPv4()+':'+this.wss.options.port.toString(); + } + start(): void { if (this.started) { console.error("Server4Flutter was already started"); @@ -316,10 +335,7 @@ export class ServerInternalImp { this.clientMiddleware.start(); - this.logger( - "Server started on " + myIPv4()+':'+this.wss.options.port.toString(), - "info" - ); + this.logger("Server started on " + this.localUrl, "info"); this.sendMessageToClientAgainTask.start( this.config["intervalInSecondsServerSendSameMessage"] * 1000 @@ -366,14 +382,13 @@ export class ServerInternalImp { } getConnectionConfiguration(clientType:'flutter'|'javascript') { - const serverVersion = environment.server.versions.find( - (v) => v.name == environment.server.current - ); let clientVersionCodeSupported; if(clientType==="javascript"){ - clientVersionCodeSupported = serverVersion.clientVersionCodeSupported.web; - }else{ //clientType == 'flutter' or clientType == null - clientVersionCodeSupported = serverVersion.clientVersionCodeSupported.flutter; + clientVersionCodeSupported = environment.server.clientVersionCodeSupported.javascript; + }else if(clientType == 'flutter' || clientType == null){ + clientVersionCodeSupported = environment.server.clientVersionCodeSupported.flutter; + }else{ + throw Error("Invalid clientType: "+clientType); } return { @@ -391,7 +406,7 @@ export class ServerInternalImp { "reconnectClientAfterSecondsWithoutServerPong" ], isFromServer: true, - serverVersion: serverVersion.name, + serverVersion: environment.server.name, clientVersionCodeSupported: { lessThanOrEqual: clientVersionCodeSupported.lessThanOrEqual, moreThanOrEqual: clientVersionCodeSupported.moreThanOrEqual, @@ -426,6 +441,10 @@ export class AsklessServer { this.server4Flutter.start(); } + get localUrl () : String { + return this.server4Flutter.localUrl; + } + /** * Gets a READ route. * @param readRoute The name of the route. @@ -574,11 +593,7 @@ export class AsklessServer { .getClientInfo(ownClientId) .doWsDisconnect(); } catch (e) { - this.server4Flutter.logger( - "Could not disconnect the client " + ownClientId, - "error", - e.stack - ); + this.server4Flutter.logger("Could not disconnect the client " + ownClientId, "error", e.stack); } } } diff --git a/src/route/ReadRoute.ts b/src/route/ReadRoute.ts index b80e02a..67f5932 100644 --- a/src/route/ReadRoute.ts +++ b/src/route/ReadRoute.ts @@ -368,10 +368,7 @@ abstract class _ReadRoute { async _notifyClientsAsync( notify?: NotifyClientsParams ): Promise { - this.server4Flutter.logger( - "notifyClients -> started " + notify.output + " " + this.route, - "debug" - ); + this.server4Flutter.logger("notifyClients -> started " + notify.output + " " + this.route, "debug"); if ( notify && @@ -388,10 +385,7 @@ abstract class _ReadRoute { if(clientId==null) //TODO: analisar porque está vindo aqui nulo, será que o delete não está funcionando direito? continue; - this.server4Flutter.logger( - "notifyClients -> client " + clientId, - "debug" - ); + this.server4Flutter.logger("notifyClients -> client " + clientId, "debug"); if (!clientId_info.hasOwnProperty(clientId)) { continue; } @@ -400,11 +394,7 @@ abstract class _ReadRoute { notify.sendToSpecificClientsIds && !notify.sendToSpecificClientsIds.includes(clientId) ) { - this.server4Flutter.logger( - "notifyClients -> Ignoring client because not informed on sendToSpecificClientsIds" + - clientId, - "debug" - ); + this.server4Flutter.logger("notifyClients -> Ignoring client because not informed on sendToSpecificClientsIds" + clientId, "debug"); continue; } @@ -412,23 +402,11 @@ abstract class _ReadRoute { const routeClientListeningByThisClient = clientInfo.routesBeingListen.find((route) => route.route == this.route); if (routeClientListeningByThisClient == null) { - this.server4Flutter.logger( - "notifyClients -> client " + - clientId + - " is not listening to " + - this.route, - "debug" - ); + this.server4Flutter.logger("notifyClients -> client " + clientId + " is not listening to " + this.route, "debug"); continue; } - this.server4Flutter.logger( - "notifyClients -> " + - clientId + - " listen to: " + - clientInfo.routesBeingListen.length, - "debug" - ); + this.server4Flutter.logger("notifyClients -> " + clientId + " listen to: " + clientInfo.routesBeingListen.length, "debug"); // noinspection PointlessBooleanExpressionJS const response: RespondSuccess | RespondError = @@ -454,10 +432,7 @@ abstract class _ReadRoute { ); if (response instanceof RespondSuccess) { - this.server4Flutter.logger( - "notifyClients -> Notifying client " + clientId, - "debug" - ); + this.server4Flutter.logger("notifyClients -> Notifying client " + clientId, "debug"); const notifyClientOrNot = (await this.realtimeOutputHandler({ @@ -478,13 +453,7 @@ abstract class _ReadRoute { notifyClientOrNot.notifyThisClient != null && notifyClientOrNot.notifyThisClient == false ) { - this.server4Flutter.logger( - this.route + - ' - Client "' + - clientId + - '" will not receive notification, because realtimeOutputHandler', - notify && notify.sendToSpecificClientsIds ? "warning" : "debug" - ); + this.server4Flutter.logger(this.route + ' - Client "' + clientId + '" will not receive notification, because realtimeOutputHandler', notify && notify.sendToSpecificClientsIds ? "warning" : "debug"); return; } @@ -516,13 +485,7 @@ abstract class _ReadRoute { } ); } else { - this.server4Flutter.logger( - "notifyClients -> " + - this.route + - " could not send the data, because read failed, try passing the output as parameter on notifyClients method", - "error", - response - ); + this.server4Flutter.logger("notifyClients -> " + this.route + " could not send the data, because read failed, try passing the output as parameter on notifyClients method", "error", response); } } @@ -560,11 +523,7 @@ abstract class _ReadRoute { self.server4Flutter.logger("listen: READ error", "error", output); if (output.code == RespondErrorCode.PERMISSION_DENIED) { - self.server4Flutter.logger( - "listen: the error is PERMISSION_DENIED, calling stopListening...", - "error", - output - ); + self.server4Flutter.logger("listen: the error is PERMISSION_DENIED, calling stopListening...", "error", output); self.stopListening(clientId, listenId, self.route); successAndNowIsListening = false; self.server4Flutter.clientMiddleware.assertSendDataToClient( @@ -606,11 +565,7 @@ abstract class _ReadRoute { ownClientId: Utils.getOwnClientId(clientId), }); else - self.server4Flutter.logger( - "onClientStartsListening not called successAndNowIsListening : " + - successAndNowIsListening.toString(), - self.onClientStartsListening ? "error" : "debug" - ); + self.server4Flutter.logger("onClientStartsListening not called successAndNowIsListening : " + successAndNowIsListening.toString(), self.onClientStartsListening ? "error" : "debug"); resolve(successAndNowIsListening ? listenId : null); }; diff --git a/src/tasks/ClearClientsThoseDisconnectedAfterATimeTask.ts b/src/tasks/ClearClientsThoseDisconnectedAfterATimeTask.ts index e7f4307..93643c2 100644 --- a/src/tasks/ClearClientsThoseDisconnectedAfterATimeTask.ts +++ b/src/tasks/ClearClientsThoseDisconnectedAfterATimeTask.ts @@ -8,10 +8,7 @@ export class ClearRuntimeDataFromDisconnectedClientTask extends AbstractTimedTas run() { if (!this.server4Flutter?.clientMiddleware?.clients) { - this.server4Flutter.logger( - "ClearRuntimeDataFromDisconnectedClientTask this.server4Flutter?.clientMiddleware?.clients IS NULL", - "error" - ); + this.server4Flutter.logger("ClearRuntimeDataFromDisconnectedClientTask this.server4Flutter?.clientMiddleware?.clients IS NULL", "error"); return; } const clientsId_clientInfo = this.server4Flutter.clientMiddleware.clients.getAllClientsInfos(); @@ -29,11 +26,7 @@ export class ClearRuntimeDataFromDisconnectedClientTask extends AbstractTimedTas 1000 < Date.now() ) { - this.server4Flutter.logger( - "Cleaning data from disconnected user " + clientId, - "debug", - clientInfo - ); + this.server4Flutter.logger("Cleaning data from disconnected user " + clientId, "debug", clientInfo); this.server4Flutter.clientMiddleware.clients.deleteClientsInfos([ clientId, ]); diff --git a/src/tasks/DisconnectClientsWhoDidntPingTask.ts b/src/tasks/DisconnectClientsWhoDidntPingTask.ts index cea8d76..f9e7646 100644 --- a/src/tasks/DisconnectClientsWhoDidntPingTask.ts +++ b/src/tasks/DisconnectClientsWhoDidntPingTask.ts @@ -12,18 +12,12 @@ export class DisconnectClientsWhoDidntPingTask extends AbstractTimedTask { run() { if (!this.server4Flutter?.wss) { - this.server4Flutter.logger( - "DisconnectClientsWhoDidntPingTask: this.server4Flutter?.wss IS NULL", - "error" - ); + this.server4Flutter.logger("DisconnectClientsWhoDidntPingTask: this.server4Flutter?.wss IS NULL", "error"); return; } this.server4Flutter.wss.clients.forEach((ws) => { if (ws[ws_isAlive] == false) { - this.server4Flutter.logger( - "Disconnecting user " + ws[ws_clientId] + " because he didn't ping", - "debug" - ); + this.server4Flutter.logger("Disconnecting user " + ws[ws_clientId] + " because he didn't ping", "debug"); return ws.terminate(); } ws[ws_isAlive] = false; diff --git a/src/tasks/SendMessageToClientAgainTask.ts b/src/tasks/SendMessageToClientAgainTask.ts index 18066b7..8d5c732 100644 --- a/src/tasks/SendMessageToClientAgainTask.ts +++ b/src/tasks/SendMessageToClientAgainTask.ts @@ -11,10 +11,7 @@ export class SendMessageToClientAgainTask extends AbstractTimedTask { run() { const clientsId_clientInfo = this.server4Flutter?.clientMiddleware?.clients?.getAllClientsInfos(); if (!this.server4Flutter?.wss) { - this.server4Flutter.logger( - "SendMessageToClientAgainTask: this.server4Flutter?.clientMiddleware?.clients?.getAllClientsInfos() IS NULL", - "error" - ); + this.server4Flutter.logger("SendMessageToClientAgainTask: this.server4Flutter?.clientMiddleware?.clients?.getAllClientsInfos() IS NULL", "error"); return; } for (let clientId in clientsId_clientInfo) {