mirror of https://github.com/MISP/misp-dashboard
Auto-reconnect if event source connection lost
parent
13305e627f
commit
366f1d826e
|
@ -103,29 +103,34 @@ sources.addSource('global');
|
|||
|
||||
var curNumLog = 0;
|
||||
var curMaxDataNumLog = 0;
|
||||
var source_log;
|
||||
|
||||
function connect_source_log() {
|
||||
source_log = new EventSource(urlForLogs);
|
||||
|
||||
source_log.onopen = function(){
|
||||
//console.log('connection is opened. '+source_log.readyState);
|
||||
};
|
||||
|
||||
source_log.onerror = function(){
|
||||
console.log('error: '+source_log.readyState);
|
||||
setTimeout(function() { connect_source_log(); }, 5000);
|
||||
};
|
||||
|
||||
source_log.onmessage = function(event) {
|
||||
var json = jQuery.parseJSON( event.data );
|
||||
updateLogTable(json.feedName, json.log);
|
||||
};
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
createHead(function() {
|
||||
if (!!window.EventSource) {
|
||||
var source_log = new EventSource(urlForLogs);
|
||||
|
||||
source_log.onopen = function(){
|
||||
//console.log('connection is opened. '+source_log.readyState);
|
||||
};
|
||||
|
||||
source_log.onerror = function(){
|
||||
console.log('error: '+source_log.readyState);
|
||||
setTimeout(function() { location.reload(); }, 5000);
|
||||
};
|
||||
|
||||
source_log.onmessage = function(event) {
|
||||
var json = jQuery.parseJSON( event.data );
|
||||
updateLogTable(json.feedName, json.log);
|
||||
};
|
||||
|
||||
connect_source_log();
|
||||
} else {
|
||||
console.log("No event source_log");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$( "#rotation_wait_time_selector" ).change(function() {
|
||||
|
|
|
@ -89,7 +89,6 @@ class MapEventManager {
|
|||
|
||||
$("#textMap1").fadeOut(400, function(){ $(this).text(mapEvent.text); }).fadeIn(400);
|
||||
if(ROTATIONWAITTIME != 0) {
|
||||
console.log(ROTATIONWAITTIME);
|
||||
this._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
|
||||
}
|
||||
}
|
||||
|
@ -159,18 +158,22 @@ $(function(){
|
|||
});
|
||||
|
||||
// Subscribe to the flask eventStream
|
||||
var source_map = new EventSource(urlForMaps);
|
||||
source_map.onmessage = function(event) {
|
||||
var json = jQuery.parseJSON( event.data );
|
||||
var marker = L.marker([json.coord.lat, json.coord.lon]).addTo(myOpenStreetMap);
|
||||
var mapEvent = new MapEvent(json, marker);
|
||||
mapEventManager.addMapEvent(mapEvent);
|
||||
|
||||
};
|
||||
source_map.onopen = function(){
|
||||
console.log('connection is opened. '+source_map.readyState);
|
||||
};
|
||||
source_map.onerror = function(){
|
||||
console.log('error: '+source_map.readyState);
|
||||
setTimeout(function() { location.reload(); }, 5000);
|
||||
};
|
||||
var source_map;
|
||||
function connect_source_map() {
|
||||
source_map = new EventSource(urlForMaps);
|
||||
source_map.onmessage = function(event) {
|
||||
var json = jQuery.parseJSON( event.data );
|
||||
var marker = L.marker([json.coord.lat, json.coord.lon]).addTo(myOpenStreetMap);
|
||||
var mapEvent = new MapEvent(json, marker);
|
||||
mapEventManager.addMapEvent(mapEvent);
|
||||
|
||||
};
|
||||
source_map.onopen = function(){
|
||||
console.log('connection is opened. '+source_map.readyState);
|
||||
};
|
||||
source_map.onerror = function(){
|
||||
console.log('error: '+source_map.readyState);
|
||||
setTimeout(function() { connect_source_map(); }, 5000);
|
||||
};
|
||||
}
|
||||
connect_source_map()
|
||||
|
|
Loading…
Reference in New Issue