update Mo 15. Jun 21:31:01 CEST 2020
This commit is contained in:
parent
eac60918c7
commit
cf882740b7
@ -36,13 +36,12 @@ app.use(bodyParser.urlencoded({
|
|||||||
|
|
||||||
// Scripte einbinden
|
// Scripte einbinden
|
||||||
var sql_cfg = require('./server/sql_cfg')(fs, bcrypt, app_cfg);
|
var sql_cfg = require('./server/sql_cfg')(fs, bcrypt, app_cfg);
|
||||||
var sql = require('./server/sql_qry')(sql_cfg, uuidv4, app_cfg);
|
var sql = require('./server/sql_qry')(sql_cfg, app_cfg);
|
||||||
var brk = require('./server/broker')(app_cfg, sql, uuidv4);
|
var brk = require('./server/broker')(app_cfg, sql, uuidv4);
|
||||||
var proof = require('./server/proof')(app_cfg, sql);
|
var waip = require('./server/waip')(io, sql, fs, brk, async, app_cfg);
|
||||||
var waip = require('./server/waip')(io, sql, fs, brk, async, app_cfg, proof);
|
|
||||||
var socket = require('./server/socket')(io, sql, app_cfg, waip);
|
var socket = require('./server/socket')(io, sql, app_cfg, waip);
|
||||||
var api = require('./server/api')(io, sql, app_cfg, waip);
|
var api = require('./server/api')(io, sql, app_cfg, waip);
|
||||||
var saver = require('./server/proof')(app_cfg, sql, waip, api, uuidv4);
|
var saver = require('./server/saver')(app_cfg, sql, waip, api, uuidv4);
|
||||||
var udp = require('./server/udp')(app_cfg, sql, saver);
|
var udp = require('./server/udp')(app_cfg, sql, saver);
|
||||||
var auth = require('./server/auth')(app, app_cfg, sql_cfg, async, bcrypt, passport, io);
|
var auth = require('./server/auth')(app, app_cfg, sql_cfg, async, bcrypt, passport, io);
|
||||||
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp, saver);
|
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp, saver);
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
module.exports = function (app_cfg, sql) {
|
|
||||||
|
|
||||||
// Module laden
|
|
||||||
const test = 'test';
|
|
||||||
|
|
||||||
function validate_waip(data, callback) {
|
|
||||||
// TODO Validierung: Einsatzdaten auf Validität prüfen
|
|
||||||
|
|
||||||
// Log
|
|
||||||
if (app_cfg.global.development) {
|
|
||||||
console.log('Validierung WAIP: ' + JSON.stringify(data));
|
|
||||||
};
|
|
||||||
|
|
||||||
callback && callback(true);
|
|
||||||
// SQL-Log
|
|
||||||
};
|
|
||||||
|
|
||||||
function validate_rmld(data, callback) {
|
|
||||||
// TODO Validierung: Rueckmeldung auf plausibilität
|
|
||||||
|
|
||||||
// Log
|
|
||||||
if (app_cfg.global.development) {
|
|
||||||
console.log('Validierung RMLD: ' + JSON.stringify(data));
|
|
||||||
};
|
|
||||||
|
|
||||||
callback && callback(true);
|
|
||||||
// SQL-Log
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
validate_waip: validate_waip,
|
|
||||||
validate_rmld: validate_rmld
|
|
||||||
};
|
|
||||||
};
|
|
||||||
140
server/saver.js
140
server/saver.js
@ -1,21 +1,79 @@
|
|||||||
module.exports = function (app_cfg, sql, waip, api, uuidv4) {
|
module.exports = function (app_cfg, sql, waip, api, uuidv4) {
|
||||||
|
|
||||||
// Module laden
|
// Module laden
|
||||||
|
const turf = require('@turf/turf');
|
||||||
|
|
||||||
// Variablen festlegen
|
// Variablen festlegen
|
||||||
var uuid_pattern = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$', 'i');
|
var uuid_pattern = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$', 'i');
|
||||||
|
|
||||||
function save_new_waip(data, app_id) {
|
// Speichern eines neuen Einsatzes
|
||||||
|
function save_new_waip(waip_data, remote_addr, app_id) {
|
||||||
if (isValidJSON(message)) {
|
// ist JSON?
|
||||||
sql.db_log('WAIP', 'Neuer Einsatz von ' + remote.address + ':' + remote.port + ': ' + message);
|
if (isValidJSON(waip_data)) {
|
||||||
|
// Daten als JSON parsen
|
||||||
|
waip_data = JSON.parse(waip_data);
|
||||||
|
// Daten validieren
|
||||||
|
validate_waip(waip_data, function (valid) {
|
||||||
|
if (valid) {
|
||||||
|
// Polygon erzeugen und zuweisen falls nicht vorhanden
|
||||||
|
if (!waip_data.ortsdaten.wgs84_area) {
|
||||||
|
var wgs_x = parseFloat(waip_data.ortsdaten.wgs84_x);
|
||||||
|
var wgs_y = parseFloat(waip_data.ortsdaten.wgs84_y);
|
||||||
|
var point = turf.point([wgs_y, wgs_x]);
|
||||||
|
var buffered = turf.buffer(point, 1, {
|
||||||
|
steps: app_cfg.global.circumcircle,
|
||||||
|
units: 'kilometers'
|
||||||
|
});
|
||||||
|
var bbox = turf.bbox(buffered);
|
||||||
|
var new_point = turf.randomPoint(1, {
|
||||||
|
bbox: bbox
|
||||||
|
});
|
||||||
|
var new_buffer = turf.buffer(new_point, 1, {
|
||||||
|
steps: app_cfg.global.circumcircle,
|
||||||
|
units: 'kilometers'
|
||||||
|
})
|
||||||
|
waip_data.ortsdaten.wgs84_area = JSON.stringify(new_buffer);
|
||||||
|
};
|
||||||
|
// pruefen, ob vielleicht schon ein Einsatz mit einer UUID gespeichert ist
|
||||||
|
db.get('select uuid from waip_einsaetze where einsatznummer like ?', [content.einsatzdaten.nummer], function (err, row) {
|
||||||
|
if (err == null && row) {
|
||||||
|
// wenn ein Einsatz mit UUID schon vorhanden ist, dann diese setzten / ueberschreiben
|
||||||
|
content.einsatzdaten.uuid = row.uuid;
|
||||||
|
} else {
|
||||||
|
// uuid erzeugen und zuweisen falls nicht bereits in JSON vorhanden
|
||||||
|
if (!content.einsatzdaten.uuid) {
|
||||||
|
content.einsatzdaten.uuid = uuidv4();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
// Einsatz in DB Speichern
|
||||||
|
waip.waip_speichern(waip_data);
|
||||||
|
sql.db_log('WAIP', 'Neuer Einsatz von ' + remote_addr + ': ' + waip_data);
|
||||||
|
// Einsatzdaten per API weiterleiten (entweder zum Server oder zum verbunden Client)
|
||||||
|
// TODO TEST: Api WAIP
|
||||||
|
api.server_to_client_new_waip(waip_data, app_id);
|
||||||
|
api.client_to_server_new_waip(waip_data, app_id);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
sql.db_log('Fehler-WAIP', 'Fehler: Einsatz von ' + remote_addr + ' nicht valide: ' + waip_data);
|
||||||
|
};
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
sql.db_log('Fehler-WAIP', 'Fehler: Einsatz von ' + remote.address + ':' + remote.port + ' Fehlerhaft: ' + message);
|
sql.db_log('Fehler-WAIP', 'Fehler: Einsatz von ' + remote_addr + ' Fehlerhaft: ' + waip_data);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
message = JSON.parse(message);
|
function save_new_rmld(data, app_id) {
|
||||||
|
|
||||||
// Funktion um zu pruefen, ob Nachricht im JSON-Format ist
|
|
||||||
|
// TODO TEST: Api WAIP
|
||||||
|
api.server_to_client_new_rmld(req.body, 'web');
|
||||||
|
api.client_to_server_new_rmld(req.body, 'web');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Funktion um zu pruefen, ob Nachricht im JSON-Format ist
|
||||||
function isValidJSON(text) {
|
function isValidJSON(text) {
|
||||||
try {
|
try {
|
||||||
JSON.parse(text);
|
JSON.parse(text);
|
||||||
@ -25,49 +83,33 @@ function save_new_waip(data, app_id) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function validate_waip(data, callback) {
|
||||||
|
// TODO Validierung: Einsatzdaten auf Validität prüfen
|
||||||
|
|
||||||
|
// Log
|
||||||
waip.waip_speichern(message);
|
if (app_cfg.global.development) {
|
||||||
// Einsatzdaten per API weiterleiten (entweder zum Server oder zum verbunden Client)
|
console.log('Validierung WAIP: ' + JSON.stringify(data));
|
||||||
// TODO TEST: Api WAIP
|
|
||||||
api.server_to_client_new_waip(message, 'udp');
|
|
||||||
api.client_to_server_new_waip(message, 'udp');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Rückmeldung an verbundenen Client senden, falls funktion aktiviert
|
|
||||||
if (app_cfg.api.enabled) {
|
|
||||||
// testen ob app_id auch eine uuid ist, falls nicht, eigene app_uuid setzen
|
|
||||||
if (!uuid_pattern.test(app_id)) {
|
|
||||||
app_id = app_cfg.global.app_id;
|
|
||||||
};
|
};
|
||||||
nsp_api.emit('from_server_to_client_new_waip', {
|
|
||||||
data: data,
|
|
||||||
app_id: app_id
|
|
||||||
});
|
|
||||||
sql.db_log('API', 'Einsatz an ' + app_cfg.endpoint.host + ' gesendet: ' + JSON.stringify(data));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
function save_new_rmld(data, app_id) {
|
callback && callback(true);
|
||||||
// Rückmeldung an verbundenen Client senden, falls funktion aktiviert
|
// SQL-Log
|
||||||
if (app_cfg.api.enabled) {
|
};
|
||||||
// testen ob app_id auch eine uuid ist, falls nicht, eigene app_uuid setzen
|
|
||||||
if (!uuid_pattern.test(app_id)) {
|
|
||||||
app_id = app_cfg.global.app_id;
|
|
||||||
};
|
|
||||||
nsp_api.emit('from_server_to_client_new_rmld', {
|
|
||||||
data: data,
|
|
||||||
app_id: app_id
|
|
||||||
});
|
|
||||||
sql.db_log('API', 'Rückmeldung an ' + app_cfg.endpoint.host + ' gesendet: ' + JSON.stringify(data));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
function validate_rmld(data, callback) {
|
||||||
|
// TODO Validierung: Rueckmeldung auf plausibilität
|
||||||
|
|
||||||
|
// Log
|
||||||
|
if (app_cfg.global.development) {
|
||||||
|
console.log('Validierung RMLD: ' + JSON.stringify(data));
|
||||||
|
};
|
||||||
|
|
||||||
|
callback && callback(true);
|
||||||
|
// SQL-Log
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
save_new_waip: save_new_waip,
|
save_new_waip: save_new_waip,
|
||||||
save_new_rmld: save_new_rmld
|
save_new_rmld: save_new_rmld
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -1,7 +1,6 @@
|
|||||||
module.exports = function (db, uuidv4, app_cfg) {
|
module.exports = function (db, app_cfg) {
|
||||||
|
|
||||||
// Module laden
|
// Module laden
|
||||||
const turf = require('@turf/turf');
|
|
||||||
const {
|
const {
|
||||||
v5: uuidv5
|
v5: uuidv5
|
||||||
} = require('uuid');
|
} = require('uuid');
|
||||||
@ -9,71 +8,40 @@ module.exports = function (db, uuidv4, app_cfg) {
|
|||||||
// SQL-Abfragen
|
// SQL-Abfragen
|
||||||
|
|
||||||
function db_einsatz_speichern(content, callback) {
|
function db_einsatz_speichern(content, callback) {
|
||||||
// Polygon erzeugen und zuweisen falls nicht vorhanden
|
// Einsatzdaten verarbeiten
|
||||||
if (!content.ortsdaten.wgs84_area) {
|
db.run(`INSERT OR REPLACE INTO waip_einsaetze (
|
||||||
var wgs_x = parseFloat(content.ortsdaten.wgs84_x);
|
id, uuid, einsatznummer, alarmzeit, einsatzart, stichwort, sondersignal, besonderheiten, ort, ortsteil, strasse, objekt, objektnr, objektart, wachenfolge, wgs84_x, wgs84_y, wgs84_area)
|
||||||
var wgs_y = parseFloat(content.ortsdaten.wgs84_y);
|
VALUES (
|
||||||
var point = turf.point([wgs_y, wgs_x]);
|
(select ID from waip_einsaetze where einsatznummer like \'` + content.einsatzdaten.nummer + `\'),
|
||||||
var buffered = turf.buffer(point, 1, {
|
\'` + content.einsatzdaten.uuid + `\',
|
||||||
steps: app_cfg.global.circumcircle,
|
\'` + content.einsatzdaten.nummer + `\',
|
||||||
units: 'kilometers'
|
\'` + content.einsatzdaten.alarmzeit + `\',
|
||||||
});
|
\'` + content.einsatzdaten.art + `\',
|
||||||
var bbox = turf.bbox(buffered);
|
\'` + content.einsatzdaten.stichwort + `\',
|
||||||
var new_point = turf.randomPoint(1, {
|
\'` + content.einsatzdaten.sondersignal + `\',
|
||||||
bbox: bbox
|
\'` + content.einsatzdaten.besonderheiten + `\',
|
||||||
});
|
\'` + content.ortsdaten.ort + `\',
|
||||||
var new_buffer = turf.buffer(new_point, 1, {
|
\'` + content.ortsdaten.ortsteil + `\',
|
||||||
steps: app_cfg.global.circumcircle,
|
\'` + content.ortsdaten.strasse + `\',
|
||||||
units: 'kilometers'
|
\'` + content.ortsdaten.objekt + `\',
|
||||||
})
|
\'` + content.ortsdaten.objektnr + `\',
|
||||||
content.ortsdaten.wgs84_area = JSON.stringify(new_buffer);
|
\'` + content.ortsdaten.objektart + `\',
|
||||||
};
|
\'` + content.ortsdaten.wachfolge + `\',
|
||||||
// pruefen, ob vielleicht schon ein Einsatz mit einer UUID gespeichert ist
|
\'` + content.ortsdaten.wgs84_x + `\',
|
||||||
db.get('select uuid from waip_einsaetze where einsatznummer like ?', [content.einsatzdaten.nummer], function (err, row) {
|
\'` + content.ortsdaten.wgs84_y + `\',
|
||||||
if (err == null && row) {
|
\'` + content.ortsdaten.wgs84_area + `\')`,
|
||||||
// wenn Einsatz mit UUID vorhanden, dann setzten
|
function (err) {
|
||||||
content.einsatzdaten.uuid = row.uuid;
|
if (err == null) {
|
||||||
} else {
|
// letzte Einsatz-ID ermitteln
|
||||||
// FIXME UUID schon vor dem weiterleiten setzen
|
var id = this.lastID;
|
||||||
// uuid erzeugen und zuweisen falls nicht vorhanden
|
// Schleife definieren
|
||||||
if (!content.einsatzdaten.uuid) {
|
function loop_done(waip_id) {
|
||||||
content.einsatzdaten.uuid = uuidv4();
|
callback && callback(waip_id);
|
||||||
};
|
};
|
||||||
};
|
var itemsProcessed = 0;
|
||||||
// Einsatzdaten verarbeiten
|
// Einsatzmittel zum Einsatz speichern
|
||||||
db.run(`INSERT OR REPLACE INTO waip_einsaetze (
|
content.alarmdaten.forEach(function (item, index, array) {
|
||||||
id, uuid, einsatznummer, alarmzeit, einsatzart, stichwort, sondersignal, besonderheiten, ort, ortsteil, strasse, objekt, objektnr, objektart, wachenfolge, wgs84_x, wgs84_y, wgs84_area)
|
db.run(`INSERT OR REPLACE INTO waip_einsatzmittel (id, waip_einsaetze_ID, waip_wachen_ID, wachenname, einsatzmittel, zeitstempel)
|
||||||
VALUES (
|
|
||||||
(select ID from waip_einsaetze where einsatznummer like \'` + content.einsatzdaten.nummer + `\'),
|
|
||||||
\'` + content.einsatzdaten.uuid + `\',
|
|
||||||
\'` + content.einsatzdaten.nummer + `\',
|
|
||||||
\'` + content.einsatzdaten.alarmzeit + `\',
|
|
||||||
\'` + content.einsatzdaten.art + `\',
|
|
||||||
\'` + content.einsatzdaten.stichwort + `\',
|
|
||||||
\'` + content.einsatzdaten.sondersignal + `\',
|
|
||||||
\'` + content.einsatzdaten.besonderheiten + `\',
|
|
||||||
\'` + content.ortsdaten.ort + `\',
|
|
||||||
\'` + content.ortsdaten.ortsteil + `\',
|
|
||||||
\'` + content.ortsdaten.strasse + `\',
|
|
||||||
\'` + content.ortsdaten.objekt + `\',
|
|
||||||
\'` + content.ortsdaten.objektnr + `\',
|
|
||||||
\'` + content.ortsdaten.objektart + `\',
|
|
||||||
\'` + content.ortsdaten.wachfolge + `\',
|
|
||||||
\'` + content.ortsdaten.wgs84_x + `\',
|
|
||||||
\'` + content.ortsdaten.wgs84_y + `\',
|
|
||||||
\'` + content.ortsdaten.wgs84_area + `\')`,
|
|
||||||
function (err) {
|
|
||||||
if (err == null) {
|
|
||||||
// letzte Einsatz-ID ermitteln
|
|
||||||
var id = this.lastID;
|
|
||||||
// Schleife definieren
|
|
||||||
function loop_done(waip_id) {
|
|
||||||
callback && callback(waip_id);
|
|
||||||
};
|
|
||||||
var itemsProcessed = 0;
|
|
||||||
// Einsatzmittel zum Einsatz speichern
|
|
||||||
content.alarmdaten.forEach(function (item, index, array) {
|
|
||||||
db.run(`INSERT OR REPLACE INTO waip_einsatzmittel (id, waip_einsaetze_ID, waip_wachen_ID, wachenname, einsatzmittel, zeitstempel)
|
|
||||||
VALUES (
|
VALUES (
|
||||||
(select ID from waip_einsatzmittel where einsatzmittel like \'` + item.einsatzmittel + `\'),
|
(select ID from waip_einsatzmittel where einsatzmittel like \'` + item.einsatzmittel + `\'),
|
||||||
\'` + id + `\',
|
\'` + id + `\',
|
||||||
@ -81,24 +49,23 @@ module.exports = function (db, uuidv4, app_cfg) {
|
|||||||
\'` + item.wachenname + `\',
|
\'` + item.wachenname + `\',
|
||||||
\'` + item.einsatzmittel + `\',
|
\'` + item.einsatzmittel + `\',
|
||||||
\'` + item.zeit_a + `\')`,
|
\'` + item.zeit_a + `\')`,
|
||||||
function (err) {
|
function (err) {
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
// Schleife erhoehen
|
// Schleife erhoehen
|
||||||
itemsProcessed++;
|
itemsProcessed++;
|
||||||
if (itemsProcessed === array.length) {
|
if (itemsProcessed === array.length) {
|
||||||
// Schleife beenden
|
// Schleife beenden
|
||||||
loop_done(id);
|
loop_done(id);
|
||||||
};
|
|
||||||
} else {
|
|
||||||
callback && callback(err);
|
|
||||||
};
|
};
|
||||||
});
|
} else {
|
||||||
});
|
callback && callback(err);
|
||||||
} else {
|
};
|
||||||
callback && callback(err);
|
});
|
||||||
};
|
});
|
||||||
});
|
} else {
|
||||||
});
|
callback && callback(err);
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function db_einsatz_ermitteln(wachen_id, socket, callback) {
|
function db_einsatz_ermitteln(wachen_id, socket, callback) {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module.exports = function (app_cfg, sql, saver) {
|
|||||||
|
|
||||||
// Warten auf Einsatzdaten
|
// Warten auf Einsatzdaten
|
||||||
udp_server.on('message', function (message, remote) {
|
udp_server.on('message', function (message, remote) {
|
||||||
saver.save_new_waip(message, 'udp')
|
saver.save_new_waip(message, remote.address + ':' + remote.port, 'udp')
|
||||||
});
|
});
|
||||||
|
|
||||||
// UDP-Daten senden
|
// UDP-Daten senden
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
module.exports = function (io, sql, fs, brk, async, app_cfg, proof) {
|
module.exports = function (io, sql, fs, brk, async, app_cfg) {
|
||||||
|
|
||||||
// Module laden
|
// Module laden
|
||||||
const json2csv = require('json2csv');
|
const json2csv = require('json2csv');
|
||||||
@ -6,52 +6,47 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, proof) {
|
|||||||
silent: true
|
silent: true
|
||||||
});
|
});
|
||||||
|
|
||||||
function waip_speichern(einsatz_rohdaten) {
|
function waip_speichern(einsatz_daten) {
|
||||||
// Einsatzmeldung in Datenbank speichern und verteilen
|
// Einsatzmeldung in Datenbank speichern und verteilen
|
||||||
proof.validate_waip(einsatz_rohdaten, function (valid) {
|
sql.db_einsatz_speichern(einsatz_daten, function (waip_id) {
|
||||||
if (valid) {
|
sql.db_log('DEBUG', 'Neuen Einsatz mit der ID ' + waip_id + ' gespeichert.');
|
||||||
// Einsatzmeldung (JSON) speichern
|
|
||||||
sql.db_einsatz_speichern(einsatz_rohdaten, function (waip_id) {
|
|
||||||
sql.db_log('DEBUG', 'Neuen Einsatz mit der ID ' + waip_id + ' gespeichert.');
|
|
||||||
|
|
||||||
// FIXME hier ungewollte Einsaetze ggf. wieder loeschen
|
// FIXME hier ungewollte Einsaetze ggf. wieder loeschen
|
||||||
|
|
||||||
// nach dem Speichern anhand der waip_id die beteiligten Wachennummern zum Einsatz ermitteln
|
// nach dem Speichern anhand der waip_id die beteiligten Wachennummern zum Einsatz ermitteln
|
||||||
sql.db_einsatz_get_rooms(waip_id, function (socket_rooms) {
|
sql.db_einsatz_get_rooms(waip_id, function (socket_rooms) {
|
||||||
if (socket_rooms) {
|
if (socket_rooms) {
|
||||||
socket_rooms.forEach(function (rooms) {
|
socket_rooms.forEach(function (rooms) {
|
||||||
// fuer jede Wache(rooms.room) die verbundenen Sockets(Clients) ermitteln und den Einsatz verteilen
|
// fuer jede Wache(rooms.room) die verbundenen Sockets(Clients) ermitteln und den Einsatz verteilen
|
||||||
var room_sockets = io.nsps['/waip'].adapter.rooms[rooms.room];
|
var room_sockets = io.nsps['/waip'].adapter.rooms[rooms.room];
|
||||||
if (typeof room_sockets !== 'undefined') {
|
if (typeof room_sockets !== 'undefined') {
|
||||||
Object.keys(room_sockets.sockets).forEach(function (socket_id) {
|
Object.keys(room_sockets.sockets).forEach(function (socket_id) {
|
||||||
var socket = io.of('/waip').connected[socket_id];
|
var socket = io.of('/waip').connected[socket_id];
|
||||||
waip_verteilen(waip_id, socket, rooms.room);
|
waip_verteilen(waip_id, socket, rooms.room);
|
||||||
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' wird an ' + socket.id + ' (' + rooms.room + ') gesendet');
|
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' wird an ' + socket.id + ' (' + rooms.room + ') gesendet');
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// wenn kein Raum (keine Wache) in der DB hinterlegt ist, dann Einsatz direkt wieder loeschen
|
|
||||||
sql.db_log('Fehler-WAIP', 'Fehler: Keine Wache für den Einsatz mit der ID ' + waip_id + ' vorhanden! Einsatz wird gelöscht!');
|
|
||||||
sql.db_einsatz_loeschen(waip_id);
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// pruefen ob für die beteiligten Wachen eine Verteiler-Liste hinterlegt ist, falls ja: Rueckmeldungs-Link senden
|
} else {
|
||||||
sql.db_vmtl_get_list(waip_id, function (list) {
|
// wenn kein Raum (keine Wache) in der DB hinterlegt ist, dann Einsatz direkt wieder loeschen
|
||||||
if (list) {
|
sql.db_log('Fehler-WAIP', 'Fehler: Keine Wache für den Einsatz mit der ID ' + waip_id + ' vorhanden! Einsatz wird gelöscht!');
|
||||||
brk.alert_vmtl_list(list, function (result) {
|
sql.db_einsatz_loeschen(waip_id);
|
||||||
if (!result) {
|
};
|
||||||
sql.db_log('VMTL', 'Link zur Einsatz-Rückmeldung erfolgreichen an Vermittler-Liste gesendet. ' + result);
|
});
|
||||||
} else {
|
// pruefen ob für die beteiligten Wachen eine Verteiler-Liste hinterlegt ist, falls ja: Rueckmeldungs-Link senden
|
||||||
sql.db_log('VMTL', 'Fehler beim senden des Links zur Einsatz-Rueckmeldung an die Vermittler-Liste: ' + result);
|
sql.db_vmtl_get_list(waip_id, function (list) {
|
||||||
};
|
if (list) {
|
||||||
});
|
brk.alert_vmtl_list(list, function (result) {
|
||||||
|
if (!result) {
|
||||||
|
sql.db_log('VMTL', 'Link zur Einsatz-Rückmeldung erfolgreichen an Vermittler-Liste gesendet. ' + result);
|
||||||
} else {
|
} else {
|
||||||
sql.db_log('VMTL', 'Keine Vermittler-Liste für Wachen im Einsatz ' + waip_id + ' hinterlegt. Rückmeldung wird nicht verteilt.');
|
sql.db_log('VMTL', 'Fehler beim senden des Links zur Einsatz-Rueckmeldung an die Vermittler-Liste: ' + result);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
};
|
sql.db_log('VMTL', 'Keine Vermittler-Liste für Wachen im Einsatz ' + waip_id + ' hinterlegt. Rückmeldung wird nicht verteilt.');
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user