diff --git a/.npmignore b/.npmignore index 98cd9320..4841bdd9 100644 --- a/.npmignore +++ b/.npmignore @@ -14,6 +14,7 @@ gulpfile.js !/README.md /admin/i18n/* lib/create-images-js.sh +admin/icons/removeBackground.js test diff --git a/README.md b/README.md index fe60c81a..618db05c 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,10 @@ by ioBroker, when you have a running 'dummy' program on the CCU which depends on Placeholder for the next version (at the beginning of the line): ### __WORK IN PROGRESS__ --> + +### __WORK IN PROGRESS__ +* (foxriver76) remove the stopInstance message handling and put everything in unload + ### 1.14.38 (2021-05-11) * (Jens Maus) fixed the VirtualDevices min/max/default assignment (fixes #332) * (foxriver76) do not scale on normal '%' UNIT because its inconsistent (fixes #326) diff --git a/io-package.json b/io-package.json index 17fe7c09..54042a43 100644 --- a/io-package.json +++ b/io-package.json @@ -290,7 +290,7 @@ "type": "iot-systems", "connectionType": "local", "dataSource": "push", - "supportStopInstance": true, + "stopTimeout": 1000, "messagebox": true, "dependencies": [ { diff --git a/main.js b/main.js index 7b136101..16ad643e 100644 --- a/main.js +++ b/main.js @@ -542,27 +542,7 @@ function startAdapter(options) { return; } - if (obj.command === 'stopInstance') { - if (rpcServer && rpcServer.server) { - try { - rpcServer.server.close(() => { - console.log('server closed.'); - rpcServer.server.unref(); - }); - } catch { - // ignore - } - } - if (rpcClient && rpcClient.socket) { - try { - rpcClient.socket.destroy(); - } catch { - // ignore - } - } - // force close - setTimeout(() => adapter.terminate ? adapter.terminate() : process.exit(), 3000); - } else if (obj.message.params === undefined || obj.message.params === null) { + if (obj.message.params === undefined || obj.message.params === null) { try { if (rpcClient && connected) { // if device specific command, send it's ID and paramType @@ -616,6 +596,7 @@ function startAdapter(options) { clearInterval(connInterval); connInterval = null; } + if (connTimeout) { clearTimeout(connTimeout); connTimeout = null; @@ -624,12 +605,33 @@ function startAdapter(options) { if (adapter.config && rpcClient) { adapter.log.info(`${adapter.config.type}rpc -> ${adapter.config.homematicAddress}:${adapter.config.homematicPort}${homematicPath} init ${JSON.stringify([daemonURL, ''])}`); try { + // tell CCU that we are no longer the client under this URL - legacy idk if necessary await rpcMethodCallAsync('init', [daemonURL, '']); if (connected) { adapter.log.info('Disconnected'); connected = false; adapter.setState('info.connection', false, true); } + + if (rpcServer && rpcServer.server) { + try { + rpcServer.server.close(() => { + console.log('server closed.'); + rpcServer.server.unref(); + }); + } catch { + // ignore + } + } + + if (rpcClient && rpcClient.socket) { + try { + rpcClient.socket.destroy(); + } catch { + // ignore + } + } + if (typeof callback === 'function') { callback(); } @@ -655,9 +657,9 @@ function startAdapter(options) { } } catch (e) { if (adapter && adapter.log) { - adapter.log.error(`Unload error: ${e}`); + adapter.log.error(`Unload error: ${e.message}`); } else { - console.log(e); + console.log(`Unload error: ${e.message}`); } if (typeof callback === 'function') { callback(); @@ -1712,7 +1714,7 @@ function connect(isFirst) { return void adapter.restart(); } // endCatch - // If we have bin-rpc, only need it here because bin-rpc cant have https + // If we have bin-rpc, only need it here because bin-rpc cannot have https if (rpcClient.on) { rpcClient.on('error', err => { adapter.log.error(`Socket error: ${err}`);