update So 7. Jun 21:01:01 CEST 2020
This commit is contained in:
parent
d4fb233a4c
commit
8c40ceb98f
@ -547,7 +547,7 @@ socket.on('io.Einsatz', function (data) {
|
|||||||
resize_text();
|
resize_text();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('io.response', function (data) {
|
socket.on('io.new_rmld', function (data) {
|
||||||
// DEBUG
|
// DEBUG
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// Neue Rueckmeldung hinterlegen
|
// Neue Rueckmeldung hinterlegen
|
||||||
|
|||||||
@ -301,7 +301,7 @@ socket.on('io.standby', function (data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Einsatzdaten laden, Wachalarm anzeigen
|
// Einsatzdaten laden, Wachalarm anzeigen
|
||||||
socket.on('io.neuerEinsatz', function (data) {
|
socket.on('io.new_waip', function (data) {
|
||||||
// DEBUG
|
// DEBUG
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// Einsatz-ID speichern
|
// Einsatz-ID speichern
|
||||||
@ -417,7 +417,7 @@ socket.on('io.neuerEinsatz', function (data) {
|
|||||||
resize_text();
|
resize_text();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('io.response', function (data) {
|
socket.on('io.new_rmld', function (data) {
|
||||||
// DEBUG
|
// DEBUG
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// Neue Rueckmeldung hinterlegen
|
// Neue Rueckmeldung hinterlegen
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
@ -17,7 +16,7 @@ const bcrypt = require('bcrypt');
|
|||||||
const passport = require('passport');
|
const passport = require('passport');
|
||||||
const uuidv4 = require('uuid/v4');
|
const uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
// Basis-Konfiguration laden und genetische App-UUID erzeugen
|
// Basis-Konfiguration laden und generische App-UUID erzeugen
|
||||||
var app_cfg = require('./server/app_cfg.js');
|
var app_cfg = require('./server/app_cfg.js');
|
||||||
app_cfg.global.app_id = uuidv4();
|
app_cfg.global.app_id = uuidv4();
|
||||||
|
|
||||||
@ -45,15 +44,15 @@ var waip = require('./server/waip')(io, sql, brk, async, app_cfg, api, proof);
|
|||||||
var socket = require('./server/socket')(io, sql, app_cfg, waip);
|
var socket = require('./server/socket')(io, sql, app_cfg, waip);
|
||||||
var udp = require('./server/udp')(app_cfg, waip, sql);
|
var udp = require('./server/udp')(app_cfg, waip, sql);
|
||||||
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, proof);
|
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp);
|
||||||
|
|
||||||
// Server starten
|
// Server starten
|
||||||
webserver.listen(app_cfg.global.https_port, function() {
|
webserver.listen(app_cfg.global.https_port, function () {
|
||||||
sql.db_log('Anwendung', 'Wachalarm-IP-Webserver auf Port ' + app_cfg.global.https_port + ' gestartet');
|
sql.db_log('Anwendung', 'Wachalarm-IP-Webserver auf Port ' + app_cfg.global.https_port + ' gestartet');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Redirect all HTTP traffic to HTTPS
|
// Redirect all HTTP traffic to HTTPS
|
||||||
http.createServer(function(req, res) {
|
http.createServer(function (req, res) {
|
||||||
var host = req.headers.host;
|
var host = req.headers.host;
|
||||||
// prüfen ob host gesetzt, sonst 404
|
// prüfen ob host gesetzt, sonst 404
|
||||||
if (typeof host !== 'undefined' && host) {
|
if (typeof host !== 'undefined' && host) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp, proof) {
|
module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp) {
|
||||||
|
|
||||||
/* ########################### */
|
/* ########################### */
|
||||||
/* ##### Statische Seiten #### */
|
/* ##### Statische Seiten #### */
|
||||||
@ -247,11 +247,9 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp,
|
|||||||
|
|
||||||
// Rueckmeldung entgegennehmen
|
// Rueckmeldung entgegennehmen
|
||||||
app.post('/rmld/:waip_uuid/:rmld_uuid', function (req, res) {
|
app.post('/rmld/:waip_uuid/:rmld_uuid', function (req, res) {
|
||||||
proof.validate_rmld(req.body, function (valid) {
|
waip.rmld_speichern(req.body, null, 'web', function (result) {
|
||||||
if (valid) {
|
|
||||||
var waip_uuid = req.body.waip_uuid;
|
var waip_uuid = req.body.waip_uuid;
|
||||||
var rmld_uuid = req.body.rmld_uuid;
|
var rmld_uuid = req.body.rmld_uuid;
|
||||||
waip.rmld_speichern(req.body, null, 'web', function (result) {
|
|
||||||
if (result) {
|
if (result) {
|
||||||
req.flash('successMessage', 'Rückmeldung erfolgreich gesendet, auf zum Einsatz!');
|
req.flash('successMessage', 'Rückmeldung erfolgreich gesendet, auf zum Einsatz!');
|
||||||
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid);
|
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid);
|
||||||
@ -260,8 +258,6 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp,
|
|||||||
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid);
|
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* ########################## */
|
/* ########################## */
|
||||||
|
|||||||
@ -288,9 +288,9 @@ module.exports = function (db, uuidv4, app_cfg) {
|
|||||||
|
|
||||||
function db_einsatz_get_old(minuten, callback) {
|
function db_einsatz_get_old(minuten, callback) {
|
||||||
// veraltete Einsaetze finden
|
// veraltete Einsaetze finden
|
||||||
db.each('SELECT id FROM waip_einsaetze WHERE zeitstempel <= datetime(\'now\',\'-' + minuten + ' minutes\')', function (err, row) {
|
db.each('SELECT id, uuid FROM waip_einsaetze WHERE zeitstempel <= datetime(\'now\',\'-' + minuten + ' minutes\')', function (err, row) {
|
||||||
if (err == null && row) {
|
if (err == null && row) {
|
||||||
callback && callback(row.id);
|
callback && callback(row);
|
||||||
} else {
|
} else {
|
||||||
callback && callback(null);
|
callback && callback(null);
|
||||||
};
|
};
|
||||||
@ -505,6 +505,17 @@ module.exports = function (db, uuidv4, app_cfg) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function db_socket_get_by_room(content, callback) {
|
||||||
|
// Client-Eintrag per Socket-ID finden
|
||||||
|
db.get('select socket_id from waip_clients where room_name = ? ', [content], function (err, row) {
|
||||||
|
if (err == null && row) {
|
||||||
|
callback && callback(row);
|
||||||
|
} else {
|
||||||
|
callback && callback(null);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function db_socket_get_all_to_standby(callback) {
|
function db_socket_get_all_to_standby(callback) {
|
||||||
// alle Sockets/Clients finden, die auf Standby gesetzt werden koennen
|
// alle Sockets/Clients finden, die auf Standby gesetzt werden koennen
|
||||||
db.all(`select socket_id from waip_clients
|
db.all(`select socket_id from waip_clients
|
||||||
@ -794,6 +805,7 @@ module.exports = function (db, uuidv4, app_cfg) {
|
|||||||
db_log: db_log,
|
db_log: db_log,
|
||||||
db_log_get_5000: db_log_get_5000,
|
db_log_get_5000: db_log_get_5000,
|
||||||
db_socket_get_by_id: db_socket_get_by_id,
|
db_socket_get_by_id: db_socket_get_by_id,
|
||||||
|
db_socket_get_by_room: db_socket_get_by_room,
|
||||||
db_socket_get_all_to_standby: db_socket_get_all_to_standby,
|
db_socket_get_all_to_standby: db_socket_get_all_to_standby,
|
||||||
db_user_set_config: db_user_set_config,
|
db_user_set_config: db_user_set_config,
|
||||||
db_user_get_config: db_user_get_config,
|
db_user_get_config: db_user_get_config,
|
||||||
|
|||||||
137
server/waip.js
137
server/waip.js
@ -1,7 +1,7 @@
|
|||||||
module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
||||||
|
|
||||||
// Einsatzmeldung in Datenbank speichern
|
|
||||||
function einsatz_speichern(einsatz_rohdaten, app_id) {
|
function einsatz_speichern(einsatz_rohdaten, app_id) {
|
||||||
|
// Einsatzmeldung in Datenbank speichern und verteilen
|
||||||
proof.validate_waip(einsatz_rohdaten, function (valid) {
|
proof.validate_waip(einsatz_rohdaten, function (valid) {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
||||||
@ -50,14 +50,15 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Einsatz an Client verteilen
|
|
||||||
function waip_verteilen(waip_id, socket, wachen_nr) {
|
function waip_verteilen(waip_id, socket, wachen_nr) {
|
||||||
// Einsatzdaten für eine Wache aus Datenbank laden
|
// Einsatzdaten für eine Wache aus Datenbank laden und an Client verteilen
|
||||||
var user_obj = socket.request.user;
|
var user_obj = socket.request.user;
|
||||||
sql.db_einsatz_get_by_waipid(waip_id, wachen_nr, user_obj.id, function (einsatzdaten) {
|
sql.db_einsatz_get_by_waipid(waip_id, wachen_nr, user_obj.id, function (einsatzdaten) {
|
||||||
if (einsatzdaten) {
|
if (einsatzdaten) {
|
||||||
// Berechtigung ueberpruefen
|
// Berechtigung ueberpruefen
|
||||||
sql.db_user_check_permission(user_obj, waip_id, function (valid) {
|
sql.db_user_check_permission(user_obj, waip_id, function (valid) {
|
||||||
|
// Wenn nutzer nicht angemeldet, Daten entfernen
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
einsatzdaten.objekt = '';
|
einsatzdaten.objekt = '';
|
||||||
einsatzdaten.besonderheiten = '';
|
einsatzdaten.besonderheiten = '';
|
||||||
@ -65,17 +66,16 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
einsatzdaten.wgs84_x = '';
|
einsatzdaten.wgs84_x = '';
|
||||||
einsatzdaten.wgs84_y = '';
|
einsatzdaten.wgs84_y = '';
|
||||||
};
|
};
|
||||||
// Einsatz senden
|
// Einsatz an Client senden
|
||||||
socket.emit('io.neuerEinsatz', einsatzdaten);
|
socket.emit('io.new_waip', einsatzdaten);
|
||||||
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' fuer Wache ' + wachen_nr + ' an Socket ' + socket.id + ' gesendet');
|
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' fuer Wache ' + wachen_nr + ' an Socket ' + socket.id + ' gesendet');
|
||||||
sql.db_client_update_status(socket, waip_id);
|
sql.db_client_update_status(socket, waip_id);
|
||||||
// Sound erstellen
|
// Sound erstellen
|
||||||
tts_erstellen(app_cfg, socket.id, einsatzdaten, function (tts) {
|
tts_erstellen(app_cfg, socket.id, einsatzdaten, function (tts) {
|
||||||
if (tts) {
|
if (tts) {
|
||||||
// Sound senden
|
// Sound senden
|
||||||
sql.db_log('WAIP', 'ttsfile: ' + tts);
|
|
||||||
//io.sockets.to(socket_id).emit('io.playtts', tts);
|
|
||||||
socket.emit('io.playtts', tts);
|
socket.emit('io.playtts', tts);
|
||||||
|
sql.db_log('WAIP', 'ttsfile: ' + tts);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -88,8 +88,10 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function rmld_speichern(rueckmeldung, host, app_id, callback) {
|
function rmld_speichern(rueckmeldung, host, app_id, callback) {
|
||||||
|
// Rueckmeldung speichern und verteilen
|
||||||
|
proof.validate_rmld(req.body, function (valid) {
|
||||||
|
if (valid) {
|
||||||
if (!host == null) {
|
if (!host == null) {
|
||||||
host = ' von ' + host;
|
host = ' von ' + host;
|
||||||
};
|
};
|
||||||
@ -106,6 +108,8 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
api.server_to_client_new_rmld(rueckmeldung, app_id);
|
api.server_to_client_new_rmld(rueckmeldung, app_id);
|
||||||
api.client_to_server_new_rmld(rueckmeldung, app_id);
|
api.client_to_server_new_rmld(rueckmeldung, app_id);
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function rmld_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
function rmld_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
||||||
// Einsatz-ID mittels Einsatz-UUID ermitteln
|
// Einsatz-ID mittels Einsatz-UUID ermitteln
|
||||||
@ -125,7 +129,7 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
sql.db_client_check_waip_id(socket_id, waip_id, function (same_id) {
|
sql.db_client_check_waip_id(socket_id, waip_id, function (same_id) {
|
||||||
if (same_id) {
|
if (same_id) {
|
||||||
var socket = io.of('/waip').connected[socket_id];
|
var socket = io.of('/waip').connected[socket_id];
|
||||||
socket.emit('io.response', rmld_obj);
|
socket.emit('io.new_rmld', rmld_obj);
|
||||||
sql.db_log('RMLD', 'Rückmeldung ' + rmld_uuid + ' für den Einsatz mit der ID ' + waip_id + ' an Wache ' + row.room + ' gesendet.');
|
sql.db_log('RMLD', 'Rückmeldung ' + rmld_uuid + ' für den Einsatz mit der ID ' + waip_id + ' an Wache ' + row.room + ' gesendet.');
|
||||||
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
||||||
};
|
};
|
||||||
@ -133,7 +137,7 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
|
|
||||||
|
|
||||||
/*socket_rooms.forEach(function (rooms) {
|
/*socket_rooms.forEach(function (rooms) {
|
||||||
io.of('/waip').to(rooms.room).emit('io.response', rmld_obj);
|
io.of('/waip').to(rooms.room).emit('io.new_rmld', rmld_obj);
|
||||||
sql.db_log('RMLD', 'Rückmeldung ' + rmld_uuid + ' für den Einsatz mit der ID ' + waip_id + ' an Wache ' + rooms.room + ' gesendet.');
|
sql.db_log('RMLD', 'Rückmeldung ' + rmld_uuid + ' für den Einsatz mit der ID ' + waip_id + ' an Wache ' + rooms.room + ' gesendet.');
|
||||||
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
||||||
});*/
|
});*/
|
||||||
@ -165,7 +169,7 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
sql.db_rmld_get_fuer_wache(waip_id, wachen_id, function (rmld_obj) {
|
sql.db_rmld_get_fuer_wache(waip_id, wachen_id, function (rmld_obj) {
|
||||||
if (rmld_obj) {
|
if (rmld_obj) {
|
||||||
// Rueckmeldung nur an den einen Socket senden
|
// Rueckmeldung nur an den einen Socket senden
|
||||||
socket.emit('io.response', rmld_obj);
|
socket.emit('io.new_rmld', rmld_obj);
|
||||||
sql.db_log('RMLD', 'Vorhandene Rückmeldungen an Socket ' + socket.id + ' gesendet.');
|
sql.db_log('RMLD', 'Vorhandene Rückmeldungen an Socket ' + socket.id + ' gesendet.');
|
||||||
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
||||||
} else {
|
} else {
|
||||||
@ -175,15 +179,45 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function dbrd_verteilen(dbrd_uuid, socket) {
|
||||||
|
sql.db_einsatz_get_by_uuid(dbrd_uuid, function (einsatzdaten) {
|
||||||
|
if (einsatzdaten) {
|
||||||
|
sql.db_user_check_permission(socket.request.user, einsatzdaten.id, function (valid) {
|
||||||
|
if (!valid) {
|
||||||
|
delete einsatzdaten.objekt;
|
||||||
|
delete einsatzdaten.besonderheiten;
|
||||||
|
delete einsatzdaten.strasse;
|
||||||
|
delete einsatzdaten.wgs84_x;
|
||||||
|
delete einsatzdaten.wgs84_y;
|
||||||
|
};
|
||||||
|
socket.emit('io.Einsatz', einsatzdaten);
|
||||||
|
sql.db_log('DBRD', 'Einsatzdaten für Dashboard ' + dbrd_uuid + ' an Socket ' + socket.id + ' gesendet');
|
||||||
|
sql.db_client_update_status(socket, dbrd_uuid);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Standby senden
|
||||||
|
socket.emit('io.standby', null);
|
||||||
|
sql.db_log('DBRD', 'Der angefragte Einsatz ' + dbrd_uuid + ' ist nicht - oder nicht mehr - vorhanden!, Standby an Socket ' + socket.id + ' gesendet.');
|
||||||
|
sql.db_client_update_status(socket, null);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Funktion um Clients "neuzustarten" (Seite remote neu laden)
|
||||||
|
|
||||||
function tts_erstellen(app_cfg, socket_id, einsatzdaten, callback) {
|
function tts_erstellen(app_cfg, socket_id, einsatzdaten, callback) {
|
||||||
// unnoetige Zeichen aus socket_id entfernen
|
// unnoetige Zeichen aus socket_id entfernen, um diese als Dateinamen zu verwenden
|
||||||
var id = socket_id.replace(/\W/g, '');
|
var id = socket_id.replace(/\W/g, '');
|
||||||
// Pfade der Sound-Dateien defeinieren
|
// Pfade der Sound-Dateien defeinieren
|
||||||
var wav_tts = process.cwd() + app_cfg.global.soundpath + id + '.wav';
|
var wav_tts = process.cwd() + app_cfg.global.soundpath + id + '.wav';
|
||||||
var mp3_tmp = process.cwd() + app_cfg.global.soundpath + id + '_tmp.mp3';
|
var mp3_tmp = process.cwd() + app_cfg.global.soundpath + id + '_tmp.mp3';
|
||||||
var mp3_tts = process.cwd() + app_cfg.global.soundpath + id + '.mp3';
|
var mp3_tts = process.cwd() + app_cfg.global.soundpath + id + '.mp3';
|
||||||
var mp3_url = app_cfg.global.mediapath + id + '.mp3';
|
var mp3_url = app_cfg.global.mediapath + id + '.mp3';
|
||||||
// Unterscheiden des Alarmgongs nach Einsatzart
|
// unterscheiden des Alarmgongs nach Einsatzart
|
||||||
if (einsatzdaten.einsatzart == "Brandeinsatz" || einsatzdaten.einsatzart == "Hilfeleistungseinsatz") {
|
if (einsatzdaten.einsatzart == "Brandeinsatz" || einsatzdaten.einsatzart == "Hilfeleistungseinsatz") {
|
||||||
var mp3_bell = process.cwd() + app_cfg.global.soundpath + 'bell_long.mp3';
|
var mp3_bell = process.cwd() + app_cfg.global.soundpath + 'bell_long.mp3';
|
||||||
} else {
|
} else {
|
||||||
@ -214,12 +248,12 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
tts_text = tts_text.replace(/-/g, " ");
|
tts_text = tts_text.replace(/-/g, " ");
|
||||||
// Sprachansage als mp3 erstellen
|
// Sprachansage als mp3 erstellen
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
//if (process.platform === "win32") {
|
// Windows
|
||||||
case 'win32':
|
case 'win32':
|
||||||
// Powershell
|
// Powershell
|
||||||
var proc = require('child_process');
|
var proc = require('child_process');
|
||||||
var commands = [
|
var commands = [
|
||||||
// TTS-Schnittstelle von Windows
|
// TTS-Schnittstelle von Windows ansprechen
|
||||||
'Add-Type -AssemblyName System.speech;' +
|
'Add-Type -AssemblyName System.speech;' +
|
||||||
'$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;' +
|
'$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;' +
|
||||||
// Ausgabedatei und Sprachtext
|
// Ausgabedatei und Sprachtext
|
||||||
@ -248,6 +282,7 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
});
|
});
|
||||||
childD.stdin.end();
|
childD.stdin.end();
|
||||||
break;
|
break;
|
||||||
|
// LINUX
|
||||||
case 'linux':
|
case 'linux':
|
||||||
// bash
|
// bash
|
||||||
var proc = require('child_process');
|
var proc = require('child_process');
|
||||||
@ -279,18 +314,19 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
});
|
});
|
||||||
childD.stdin.end();
|
childD.stdin.end();
|
||||||
break;
|
break;
|
||||||
// } else {
|
// anderes OS
|
||||||
default:
|
default:
|
||||||
sql.db_log('Fehler-TTS', 'TTS für dieses Server-Betriebssystem nicht verfügbar');
|
sql.db_log('Fehler-TTS', 'TTS für dieses Server-Betriebssystem nicht verfügbar!');
|
||||||
callback && callback(null);
|
callback && callback(null);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aufräumen (alle 10 Sekunden)
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
// alle User-Einstellungen prüfen und ggf. Standby senden
|
|
||||||
|
// Aufräumen (alle 10 Sekunden)
|
||||||
sql.db_socket_get_all_to_standby(function (socket_ids) {
|
sql.db_socket_get_all_to_standby(function (socket_ids) {
|
||||||
|
// alle User-Einstellungen prüfen und ggf. Standby senden
|
||||||
if (socket_ids) {
|
if (socket_ids) {
|
||||||
socket_ids.forEach(function (row) {
|
socket_ids.forEach(function (row) {
|
||||||
var socket = io.of('/waip').connected[row.socket_id];
|
var socket = io.of('/waip').connected[row.socket_id];
|
||||||
@ -301,21 +337,22 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// Nach alten Einsaetzen suchen und diese ggf. loeschen
|
|
||||||
sql.db_einsatz_get_old(app_cfg.global.time_to_delete_waip, function (waip_id) {
|
sql.db_einsatz_get_old(app_cfg.global.time_to_delete_waip, function (waip) {
|
||||||
if (waip_id) {
|
// nach alten Einsaetzen suchen und diese ggf. loeschen
|
||||||
sql.db_log('WAIP', 'Einsatz mit der ID ' + waip_id + ' ist veraltet und kann gelöscht werden.')
|
if (waip) {
|
||||||
//beteiligte Wachen ermitteln
|
sql.db_log('WAIP', 'Einsatz mit der ID ' + waip.id + ' ist veraltet und kann gelöscht werden.')
|
||||||
sql.db_einsatz_get_rooms(waip_id, function (data) {
|
// beteiligte Wachen zum Einsatz ermitteln
|
||||||
|
sql.db_einsatz_get_rooms(waip.id, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
data.forEach(function (row) {
|
data.forEach(function (row) {
|
||||||
// fuer jede Wache(row.room) die verbundenen Sockets(Clients) ermitteln und Standby senden
|
// fuer jede Wache (row.room) die verbundenen Sockets(Clients) ermitteln und Standby senden
|
||||||
var room_sockets = io.nsps['/waip'].adapter.rooms[row.room];
|
var room_sockets = io.nsps['/waip'].adapter.rooms[row.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) {
|
||||||
// Standby senden
|
// Standby senden
|
||||||
var socket = io.of('/waip').connected[socket_id];
|
var socket = io.of('/waip').connected[socket_id];
|
||||||
sql.db_client_check_waip_id(socket.id, waip_id, function (same_id) {
|
sql.db_client_check_waip_id(socket.id, waip.id, function (same_id) {
|
||||||
if (same_id) {
|
if (same_id) {
|
||||||
socket.emit('io.standby', null);
|
socket.emit('io.standby', null);
|
||||||
socket.emit('io.stopaudio', null);
|
socket.emit('io.stopaudio', null);
|
||||||
@ -328,13 +365,24 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// TODO: an Dashboard senden, das der Einsatz gelöscht wurde
|
// TODO: an Dashboard senden, das der Einsatz gelöscht wurde waip.uuid
|
||||||
|
sql.db_socket_get_by_room(waip.uuid, function (socket_ids) {
|
||||||
|
if (socket_ids) {
|
||||||
|
socket_ids.forEach(function (row) {
|
||||||
|
var socket = io.of('/dbrd').connected[row.socket_id];
|
||||||
|
socket.emit('io.standby', null);
|
||||||
|
sql.db_log('WAIP', 'Standby an Socket ' + socket.id + ' gesendet');
|
||||||
|
sql.db_client_update_status(socket, null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
)};
|
||||||
// FIXME: Rueckmeldung löschen, und vorher backup
|
// FIXME: Rueckmeldung löschen, und vorher backup
|
||||||
// Einsatz löschen
|
// Einsatz löschen
|
||||||
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' wird gelöscht');
|
sql.db_log('WAIP', 'Einsatz ' + waip.id + ' wird gelöscht');
|
||||||
sql.db_einsatz_loeschen(waip_id);
|
sql.db_einsatz_loeschen(waip.id);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// löschen alter Sounddaten nach alter (15min) und socket-id (nicht mehr verbunden)
|
// löschen alter Sounddaten nach alter (15min) und socket-id (nicht mehr verbunden)
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
fs.readdirSync(process.cwd() + app_cfg.global.soundpath).forEach(file => {
|
fs.readdirSync(process.cwd() + app_cfg.global.soundpath).forEach(file => {
|
||||||
@ -352,35 +400,6 @@ module.exports = function (io, sql, brk, async, app_cfg, api, proof) {
|
|||||||
})
|
})
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
function dbrd_verteilen(dbrd_uuid, socket) {
|
|
||||||
console.log(JSON.stringify(dbrd_uuid));
|
|
||||||
sql.db_einsatz_get_by_uuid(dbrd_uuid, function (einsatzdaten) {
|
|
||||||
if (einsatzdaten) {
|
|
||||||
sql.db_user_check_permission(socket.request.user, einsatzdaten.id, function (valid) {
|
|
||||||
if (!valid) {
|
|
||||||
delete einsatzdaten.objekt;
|
|
||||||
delete einsatzdaten.besonderheiten;
|
|
||||||
delete einsatzdaten.strasse;
|
|
||||||
delete einsatzdaten.wgs84_x;
|
|
||||||
delete einsatzdaten.wgs84_y;
|
|
||||||
};
|
|
||||||
socket.emit('io.Einsatz', einsatzdaten);
|
|
||||||
sql.db_log('DBRD', 'Einsatzdaten für Dashboard ' + dbrd_uuid + ' an Socket ' + socket.id + ' gesendet');
|
|
||||||
sql.db_client_update_status(socket, dbrd_uuid);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Standby senden
|
|
||||||
socket.emit('io.standby', null);
|
|
||||||
sql.db_log('DBRD', 'Der angefragte Einsatz ' + dbrd_uuid + ' ist nicht - oder nicht mehr - vorhanden!, Standby an Socket ' + socket.id + ' gesendet.');
|
|
||||||
sql.db_client_update_status(socket, null);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Funktion um Clients "neuzustarten" (Seite remote neu laden)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
einsatz_speichern: einsatz_speichern,
|
einsatz_speichern: einsatz_speichern,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user