Added some debugging code to check frontend-backend connection

This commit is contained in:
Rick Falkvinge
2017-02-18 12:52:40 +01:00
parent 7dc96f064d
commit eba835e0b6
2 changed files with 169 additions and 112 deletions
+15 -1
View File
@@ -5,6 +5,8 @@ using System.Net;
using System.Threading;
using Mono.Unix;
using Mono.Unix.Native;
using Newtonsoft.Json.Linq;
using Swarmops.Backend.SocketServices;
using Swarmops.Common.ExtensionMethods;
using Swarmops.Database;
using Swarmops.Logic.Communications;
@@ -199,7 +201,7 @@ namespace Swarmops.Backend
int backendSocketPort = SystemSettings.WebsocketPortBackend;
_socketServer = new WebSocketServer(backendSocketPort);
// TODO: ADD SERVICE
_socketServer.AddWebSocketService<BackendServices>("/Back");
_socketServer.Start();
// Begin maintenance loop
@@ -343,6 +345,8 @@ namespace Swarmops.Backend
SystemSettings.HeartbeatBackend = (ulong) DateTime.UtcNow.ToUnix();
CommsTransmitter.Run();
BroadcastTimestamp();
try
{
/*TestTrace("Running EventProcessor.Run()...");
@@ -818,6 +822,16 @@ namespace Swarmops.Backend
}
}
private static void BroadcastTimestamp()
{
JObject json = new JObject();
json["messageType"] = "Timestamp";
json["Timestamp"] = DateTime.UtcNow.ToUnix();
_socketServer.WebSocketServices.Broadcast(json.ToString());
}
private static WebSocketServer _socketServer;
}
}