From 04d3a2be128956a3e6c8ab70ee0af3f7fc076f6b Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 31 May 2020 19:01:01 +0200 Subject: [PATCH] update So 31. Mai 19:01:01 CEST 2020 --- server/api.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/server/api.js b/server/api.js index ca6771e..7b53fa2 100755 --- a/server/api.js +++ b/server/api.js @@ -22,12 +22,12 @@ module.exports = function (io, sql, app_cfg, waip) { // in Liste der Clients mit aufnehmen sql.db_client_update_status(socket, 'api'); // Neuen Einsatz speichern - socket.on('api_new_waip', function (data) { + socket.on('emit_new_waip', function (data) { waip.einsatz_speichern(data); sql.db_log('API', 'Neuer Einsatz von ' + remote_ip + ': ' + data); }); // neue externe Rueckmeldung speichern - socket.on('api_new_rmld', function (data) { + socket.on('emit_new_rmld', function (data) { sql.db_rmld_save(data, function (result) { if (result) { waip.rmld_verteilen_by_uuid(data.waip_uuid, data.rmld_uuid); @@ -73,12 +73,24 @@ module.exports = function (io, sql, app_cfg, waip) { // neuer Einsatz vom Endpoint-Server remote_api.on('res_new_waip', function (data) { - sql.db_log('API', 'Verbindung zu ' + app_cfg.endpoint.host + ' verloren, Fehler: ' + reason); + waip.einsatz_speichern(data); + sql.db_log('API', 'Neuer Einsatz von ' + app_cfg.endpoint.host + ': ' + data); }); + // neue Rückmeldung vom Endpoint-Server + remote_api.on('res_new_rmld', function (data) { + sql.db_rmld_save(data, function (result) { + if (result) { + waip.rmld_verteilen_by_uuid(data.waip_uuid, data.rmld_uuid); + sql.db_log('API', 'Rückmeldung von ' + app_cfg.endpoint.host + ' gespeichert: ' + result); + } else { + sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + app_cfg.endpoint.host + ': ' + data); + }; + }); + }); }; - function send_new_waip(data) { + function endpoint_emit_new_waip(data) { // Alarm an Remote-Server senden, falls funktion aktiviert if (app_cfg.endpoint.enabled) { remote_api.emit('emit_new_waip', data); @@ -86,7 +98,7 @@ module.exports = function (io, sql, app_cfg, waip) { }; }; - function send_new_rmld(data) { + function endpoint_emit_new_rmld(data) { // Rückmeldung an Remote-Server senden, falls funktion aktiviert if (app_cfg.endpoint.enabled) { remote_api.emit('emit_new_rmld', data);