Added internal heartbeats from backend

This commit is contained in:
Falkvinge
2017-03-22 17:53:25 +01:00
parent 8dbc95d4e5
commit 29a1cc31cf
+17
View File
@@ -293,6 +293,7 @@ namespace Swarmops.Backend
// Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime)
int iterationCount = 0;
DateTime utcNow = DateTime.UtcNow;
while (utcNow < cycleEndTime && !exitFlag)
{
@@ -327,6 +328,13 @@ namespace Swarmops.Backend
}
utcNow = DateTime.UtcNow;
// Every second, send an internal heartbeat
if (iterationCount++%4 == 0)
{
InternalHeartbeat();
}
}
}
}
@@ -840,6 +848,15 @@ namespace Swarmops.Backend
}
}
private static void InternalHeartbeat()
{
JObject json = new JObject();
json["MessageType"] = "InternalHeartbeat";
json["Timestamp"] = DateTime.UtcNow.ToUnix();
_socketServer.WebSocketServices.Broadcast(json.ToString());
}
private static void BroadcastTimestamp()
{
JObject json = new JObject();