update and fix communication

This commit is contained in:
Martin Karkowski 2021-05-13 10:04:51 +02:00
parent c1dfbde418
commit 9f879e3a56
4 changed files with 82 additions and 65 deletions

View File

@ -225,7 +225,7 @@ export class Bridge implements ICommunicationBridge {
for (const method of EMITTING_METHODS) { for (const method of EMITTING_METHODS) {
const eventName = LAYER_METHOD_TO_EVENT[method]; const eventName = LAYER_METHOD_TO_EVENT[method];
this[method] = async (data) => { this[method] = async (data) => {
if (method !== "emitStatusUpdate") _this._emit(eventName, null, data); _this._emit(eventName, null, data);
}; };
} }
for (const method of EMITTING_SPECIFIC_METHODS) { for (const method of EMITTING_SPECIFIC_METHODS) {

View File

@ -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( this.registerInternalInstanceGenerator(
"*", "*",
async (dispather, description) => { 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) { if (this._logger) {
this._logger.info("initialized"); this._logger.info("initialized");
} }
await this.communicator.emitBonjour(this._genAliveMessage());
// await this.emitBonjour();
this.ready.setContent(true); this.ready.setContent(true);
} }

View File

@ -30,86 +30,86 @@
}, },
"homepage": "https://github.com/anti-held-333/nope-backend#readme", "homepage": "https://github.com/anti-held-333/nope-backend#readme",
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.32", "@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-brands-svg-icons": "^5.15.1", "@fortawesome/free-brands-svg-icons": "^5.15.3",
"@fortawesome/free-solid-svg-icons": "^5.15.1", "@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/react-fontawesome": "^0.1.12", "@fortawesome/react-fontawesome": "^0.1.14",
"@grpc/proto-loader": "^0.5.5", "@grpc/proto-loader": "^0.6.1",
"@openapitools/openapi-generator-cli": "^2.0.3", "@openapitools/openapi-generator-cli": "^2.2.6",
"@rjsf/bootstrap-4": "^2.4.0", "@rjsf/bootstrap-4": "^2.5.1",
"@rjsf/core": "^2.4.0", "@rjsf/core": "^2.5.1",
"@zeit/next-css": "^1.0.1", "@zeit/next-css": "^1.0.1",
"ace-builds": "^1.4.12", "ace-builds": "^1.4.12",
"aedes": "^0.44.1", "aedes": "^0.46.0",
"ajv": "^6.12.6", "ajv": "^8.1.0",
"amqplib": "^0.6.0", "amqplib": "^0.7.1",
"arangojs": "^7.1.0", "arangojs": "^7.5.0",
"async": "^3.2.0", "async": "^3.2.0",
"asyncjs": "0.0.13", "asyncjs": "0.0.13",
"bootstrap": "^4.5.3", "bootstrap": "^4.6.0",
"bootswatch": "^4.5.3", "bootswatch": "^4.6.0",
"chroma-js": "^2.1.0", "chroma-js": "^2.1.1",
"comment-parser": "^0.7.6", "comment-parser": "^1.1.5",
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.17.1", "express": "^4.17.1",
"express-openapi": "^7.0.2", "express-openapi": "^8.0.0",
"gojs": "^2.1.30", "gojs": "^2.1.38",
"gojs-react": "^1.0.10", "gojs-react": "^1.0.10",
"grpc": "^1.24.3", "grpc": "^1.24.7",
"handlebars": "^4.7.6", "handlebars": "^4.7.7",
"inquirer": "^7.3.3", "inquirer": "^8.0.0",
"inquirer-fuzzy-path": "^2.3.0", "inquirer-fuzzy-path": "^2.3.0",
"inversify": "^5.0.1", "inversify": "^5.0.5",
"js-logger": "^1.6.1", "js-logger": "^1.6.1",
"jsdocs": "^1.0.0", "jsdocs": "^1.0.0",
"lodash": "^4.17.20", "lodash": "^4.17.21",
"mathjs": "^7.5.1", "mathjs": "^9.3.2",
"mqtt": "^4.2.6", "mqtt": "^4.2.6",
"mqtt-pattern": "^1.2.0", "mqtt-pattern": "^1.2.0",
"next": "^10.0.0", "next": "^10.1.3",
"node-ads": "^1.5.1", "node-ads": "^1.5.1",
"node-rest-client": "^3.1.0", "node-rest-client": "^3.1.0",
"node-windows": "^1.0.0-beta.5", "node-windows": "^1.0.0-beta.5",
"node-wol": "^0.1.1", "node-wol": "^0.1.1",
"npm": "^7.5.2", "npm": "^7.11.0",
"npx": "^10.2.2", "npx": "^10.2.2",
"openapi-typescript-codegen": "^0.5.3", "openapi-typescript-codegen": "^0.9.3",
"rctx-contextmenu": "^1.3.4", "rctx-contextmenu": "^1.3.4",
"react": "^17.0.1", "react": "^17.0.2",
"react-ace": "^9.2.0", "react-ace": "^9.4.0",
"react-bootstrap": "^1.4.0", "react-bootstrap": "^1.5.2",
"react-dom": "^17.0.1", "react-dom": "^17.0.2",
"react-grid-layout": "^1.1.1", "react-grid-layout": "^1.2.4",
"react-icons": "^3.11.0", "react-icons": "^4.2.0",
"react-toastify": "^6.0.9", "react-toastify": "^7.0.4",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rxjs": "^6.6.3", "rxjs": "^6.6.7",
"simple-git": "^2.34.2", "simple-git": "^2.38.0",
"simple-undo": "^1.0.2", "simple-undo": "^1.0.2",
"socket.io": "^2.3.0", "socket.io": "^2.3.0",
"socket.io-client": "^2.3.1", "socket.io-client": "^2.3.1",
"swagger-ts-client": "^0.9.6", "swagger-ts-client": "^0.9.6",
"swagger-ui-react": "^3.36.0", "swagger-ui-react": "^3.47.1",
"ts-morph": "^8.1.2", "ts-morph": "^10.0.2",
"typescript-json-schema": "^0.43.0", "typescript-json-schema": "^0.50.0",
"uuid": "^8.3.1", "uuid": "^8.3.2",
"websocket-stream": "^5.5.2" "websocket-stream": "^5.5.2"
}, },
"devDependencies": { "devDependencies": {
"@types/amqplib": "^0.5.15", "@types/amqplib": "^0.5.17",
"@types/express": "^4.17.8", "@types/express": "^4.17.11",
"@types/lodash": "^4.14.162", "@types/lodash": "^4.14.168",
"@types/node": "^14.14.5", "@types/node": "^14.14.41",
"@types/react": "^16.9.53", "@types/react": "^17.0.3",
"@types/socket.io": "^2.1.11", "@types/socket.io": "^2.1.13",
"@types/socket.io-client": "^1.4.34", "@types/socket.io-client": "^1.4.36",
"@typescript-eslint/eslint-plugin": "^4.8.1", "@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.8.1", "@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.13.0", "eslint": "^7.24.0",
"eslint-config-prettier": "^6.15.0", "eslint-config-prettier": "^8.2.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.4.0",
"npm-check-updates": "^9.2.3", "npm-check-updates": "^11.5.1",
"prettier": "^2.2.0", "prettier": "^2.2.1",
"typescript": "^4.0.5" "typescript": "^4.2.4"
} }
} }

View File

@ -15,7 +15,6 @@ import { ICommunicationBridge } from "../lib/types/nope/nopeCommunication.interf
import "./graph.css"; import "./graph.css";
export default function App({ Component, pageProps, hostname }) { export default function App({ Component, pageProps, hostname }) {
console.log(hostname);
const bridge = (new Bridge( const bridge = (new Bridge(
"browser", "browser",
"bridge", "bridge",
@ -26,15 +25,23 @@ export default function App({ Component, pageProps, hostname }) {
true true
); );
const dispatcher = getDispatcher( const dispatcher: any = getDispatcher(
{ {
communicator: bridge, communicator: bridge,
logger: getNopeLogger("dispatcher", "debug") logger: getNopeLogger("dispatcher", "info")
}, },
nopeDispatcherManager nopeDispatcherManager
); );
useEffect(() => { useEffect(() => {
const dispatcher: any = getDispatcher(
{
communicator: bridge,
logger: getNopeLogger("dispatcher", "info")
},
nopeDispatcherManager
);
return () => { return () => {
// componentwillunmount in functional component. // componentwillunmount in functional component.
// Anything in here is fired on component unmount. // Anything in here is fired on component unmount.