From 9f879e3a56288f3846d36e080b396c1453c91d07 Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Thu, 13 May 2021 10:04:51 +0200 Subject: [PATCH] update and fix communication --- lib/communication/bridge.ts | 2 +- lib/dispatcher/nopeDispatcher.ts | 22 +++++-- package.json | 110 +++++++++++++++---------------- pages/_app.tsx | 13 +++- 4 files changed, 82 insertions(+), 65 deletions(-) diff --git a/lib/communication/bridge.ts b/lib/communication/bridge.ts index 9948130..b04be44 100644 --- a/lib/communication/bridge.ts +++ b/lib/communication/bridge.ts @@ -225,7 +225,7 @@ export class Bridge implements ICommunicationBridge { for (const method of EMITTING_METHODS) { const eventName = LAYER_METHOD_TO_EVENT[method]; this[method] = async (data) => { - if (method !== "emitStatusUpdate") _this._emit(eventName, null, data); + _this._emit(eventName, null, data); }; } for (const method of EMITTING_SPECIFIC_METHODS) { diff --git a/lib/dispatcher/nopeDispatcher.ts b/lib/dispatcher/nopeDispatcher.ts index 492bc57..934f87d 100644 --- a/lib/dispatcher/nopeDispatcher.ts +++ b/lib/dispatcher/nopeDispatcher.ts @@ -814,11 +814,6 @@ export class nopeDispatcher implements INopeDispatcher { ); } - this.communicator.connected.subscribe((connected) => { - // Handle an unconnect. - if (connected) _this.communicator.emitBonjour(_this._genAliveMessage()); - }); - this.registerInternalInstanceGenerator( "*", async (dispather, description) => { @@ -954,10 +949,25 @@ export class nopeDispatcher implements INopeDispatcher { } }); + this.communicator.connected.subscribe((connected) => { + // Handle an unconnect. + if (connected) { + if (RUNNINGINNODE) { + _this.emitBonjour(); + } else { + setTimeout(() => { + console.log("HERE"); + _this.emitBonjour(); + }, 2000); + } + } + }); + if (this._logger) { this._logger.info("initialized"); } - await this.communicator.emitBonjour(this._genAliveMessage()); + + // await this.emitBonjour(); this.ready.setContent(true); } diff --git a/package.json b/package.json index 00d0e46..281cc3d 100644 --- a/package.json +++ b/package.json @@ -30,86 +30,86 @@ }, "homepage": "https://github.com/anti-held-333/nope-backend#readme", "dependencies": { - "@fortawesome/fontawesome-svg-core": "^1.2.32", - "@fortawesome/free-brands-svg-icons": "^5.15.1", - "@fortawesome/free-solid-svg-icons": "^5.15.1", - "@fortawesome/react-fontawesome": "^0.1.12", - "@grpc/proto-loader": "^0.5.5", - "@openapitools/openapi-generator-cli": "^2.0.3", - "@rjsf/bootstrap-4": "^2.4.0", - "@rjsf/core": "^2.4.0", + "@fortawesome/fontawesome-svg-core": "^1.2.35", + "@fortawesome/free-brands-svg-icons": "^5.15.3", + "@fortawesome/free-solid-svg-icons": "^5.15.3", + "@fortawesome/react-fontawesome": "^0.1.14", + "@grpc/proto-loader": "^0.6.1", + "@openapitools/openapi-generator-cli": "^2.2.6", + "@rjsf/bootstrap-4": "^2.5.1", + "@rjsf/core": "^2.5.1", "@zeit/next-css": "^1.0.1", "ace-builds": "^1.4.12", - "aedes": "^0.44.1", - "ajv": "^6.12.6", - "amqplib": "^0.6.0", - "arangojs": "^7.1.0", + "aedes": "^0.46.0", + "ajv": "^8.1.0", + "amqplib": "^0.7.1", + "arangojs": "^7.5.0", "async": "^3.2.0", "asyncjs": "0.0.13", - "bootstrap": "^4.5.3", - "bootswatch": "^4.5.3", - "chroma-js": "^2.1.0", - "comment-parser": "^0.7.6", + "bootstrap": "^4.6.0", + "bootswatch": "^4.6.0", + "chroma-js": "^2.1.1", + "comment-parser": "^1.1.5", "cors": "^2.8.5", "express": "^4.17.1", - "express-openapi": "^7.0.2", - "gojs": "^2.1.30", + "express-openapi": "^8.0.0", + "gojs": "^2.1.38", "gojs-react": "^1.0.10", - "grpc": "^1.24.3", - "handlebars": "^4.7.6", - "inquirer": "^7.3.3", + "grpc": "^1.24.7", + "handlebars": "^4.7.7", + "inquirer": "^8.0.0", "inquirer-fuzzy-path": "^2.3.0", - "inversify": "^5.0.1", + "inversify": "^5.0.5", "js-logger": "^1.6.1", "jsdocs": "^1.0.0", - "lodash": "^4.17.20", - "mathjs": "^7.5.1", + "lodash": "^4.17.21", + "mathjs": "^9.3.2", "mqtt": "^4.2.6", "mqtt-pattern": "^1.2.0", - "next": "^10.0.0", + "next": "^10.1.3", "node-ads": "^1.5.1", "node-rest-client": "^3.1.0", "node-windows": "^1.0.0-beta.5", "node-wol": "^0.1.1", - "npm": "^7.5.2", + "npm": "^7.11.0", "npx": "^10.2.2", - "openapi-typescript-codegen": "^0.5.3", + "openapi-typescript-codegen": "^0.9.3", "rctx-contextmenu": "^1.3.4", - "react": "^17.0.1", - "react-ace": "^9.2.0", - "react-bootstrap": "^1.4.0", - "react-dom": "^17.0.1", - "react-grid-layout": "^1.1.1", - "react-icons": "^3.11.0", - "react-toastify": "^6.0.9", + "react": "^17.0.2", + "react-ace": "^9.4.0", + "react-bootstrap": "^1.5.2", + "react-dom": "^17.0.2", + "react-grid-layout": "^1.2.4", + "react-icons": "^4.2.0", + "react-toastify": "^7.0.4", "reflect-metadata": "^0.1.13", - "rxjs": "^6.6.3", - "simple-git": "^2.34.2", + "rxjs": "^6.6.7", + "simple-git": "^2.38.0", "simple-undo": "^1.0.2", "socket.io": "^2.3.0", "socket.io-client": "^2.3.1", "swagger-ts-client": "^0.9.6", - "swagger-ui-react": "^3.36.0", - "ts-morph": "^8.1.2", - "typescript-json-schema": "^0.43.0", - "uuid": "^8.3.1", + "swagger-ui-react": "^3.47.1", + "ts-morph": "^10.0.2", + "typescript-json-schema": "^0.50.0", + "uuid": "^8.3.2", "websocket-stream": "^5.5.2" }, "devDependencies": { - "@types/amqplib": "^0.5.15", - "@types/express": "^4.17.8", - "@types/lodash": "^4.14.162", - "@types/node": "^14.14.5", - "@types/react": "^16.9.53", - "@types/socket.io": "^2.1.11", - "@types/socket.io-client": "^1.4.34", - "@typescript-eslint/eslint-plugin": "^4.8.1", - "@typescript-eslint/parser": "^4.8.1", - "eslint": "^7.13.0", - "eslint-config-prettier": "^6.15.0", - "eslint-plugin-prettier": "^3.1.4", - "npm-check-updates": "^9.2.3", - "prettier": "^2.2.0", - "typescript": "^4.0.5" + "@types/amqplib": "^0.5.17", + "@types/express": "^4.17.11", + "@types/lodash": "^4.14.168", + "@types/node": "^14.14.41", + "@types/react": "^17.0.3", + "@types/socket.io": "^2.1.13", + "@types/socket.io-client": "^1.4.36", + "@typescript-eslint/eslint-plugin": "^4.22.0", + "@typescript-eslint/parser": "^4.22.0", + "eslint": "^7.24.0", + "eslint-config-prettier": "^8.2.0", + "eslint-plugin-prettier": "^3.4.0", + "npm-check-updates": "^11.5.1", + "prettier": "^2.2.1", + "typescript": "^4.2.4" } } diff --git a/pages/_app.tsx b/pages/_app.tsx index 00b5798..90b5536 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -15,7 +15,6 @@ import { ICommunicationBridge } from "../lib/types/nope/nopeCommunication.interf import "./graph.css"; export default function App({ Component, pageProps, hostname }) { - console.log(hostname); const bridge = (new Bridge( "browser", "bridge", @@ -26,15 +25,23 @@ export default function App({ Component, pageProps, hostname }) { true ); - const dispatcher = getDispatcher( + const dispatcher: any = getDispatcher( { communicator: bridge, - logger: getNopeLogger("dispatcher", "debug") + logger: getNopeLogger("dispatcher", "info") }, nopeDispatcherManager ); useEffect(() => { + const dispatcher: any = getDispatcher( + { + communicator: bridge, + logger: getNopeLogger("dispatcher", "info") + }, + nopeDispatcherManager + ); + return () => { // componentwillunmount in functional component. // Anything in here is fired on component unmount.