diff --git a/public/js/client_waip.js b/public/js/client_waip.js index 61eb869..84eebbd 100644 --- a/public/js/client_waip.js +++ b/public/js/client_waip.js @@ -418,6 +418,14 @@ socket.on('io.neuerEinsatz', function (data) { map.fitBounds(geojson.getBounds()); map.setZoom(13); }; + // Rueckmeldung leeren + $('#pg-ek').empty(); + $('#pg-ma').empty(); + $('#pg-fk').empty(); + $('#ek-counter').text(0); + $('#ma-counter').text(0); + $('#fk-counter').text(0); + $('#agt-counter').text(0); // Hilfsfrist setzen start_counter(data.zeitstempel, data.ablaufzeit); // Uhr ausblenden diff --git a/server/waip.js b/server/waip.js index 9a202f6..986a9b5 100755 --- a/server/waip.js +++ b/server/waip.js @@ -87,19 +87,50 @@ module.exports = function (io, sql, tw, async, app_cfg) { // am Einsatz beteilite Socket-Räume ermitteln sql.db_get_einsatz_rooms(waip_id, function (socket_rooms) { if (socket_rooms) { - // wenn Raum zum Einsatz vorhanden ist, dann Rueckmeldung aus DB laden und an diesen versenden - sql.db_get_single_response_by_rmlduuid(rmld_uuid, function (rmld_obj) { - if (rmld_obj) { - // Rückmeldung an Clients/Räume senden - socket_rooms.forEach(function (rooms) { - io.of('/waip').to(rooms.room).emit('io.response', 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('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj)); + socket_rooms.forEach(function (row) { + // fuer jede Wache(row.room) die verbundenen Sockets(Clients) ermitteln und Standby senden + var room_sockets = io.nsps['/waip'].adapter.rooms[row.room]; + if (typeof room_sockets !== 'undefined') { + Object.keys(room_sockets.sockets).forEach(function (socket_id) { + // wenn Raum zum Einsatz aufgerufen ist, dann Rueckmeldung aus DB laden und an diesen versenden + sql.db_get_single_response_by_rmlduuid(rmld_uuid, function (rmld_obj) { + if (rmld_obj) { + // Rückmeldung an Clients/Räume senden, wenn richtiger Einsatz angezeigt wird + sql.db_check_client_waipid(socket_id, waip_id, function (same_id) { + if (same_id) { + var socket = io.of('/waip').connected[socket_id]; + socket.emit('io.response', 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('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj)); + }; + }); + + + /*socket_rooms.forEach(function (rooms) { + io.of('/waip').to(rooms.room).emit('io.response', 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('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj)); + });*/ + }; + }); + + + + }); }; }); - }; + }; }); + + + + + + + + + }); };