From 0f6d01e211dcced0a656ce06c3bc24bee2446855 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 12 Jan 2017 20:46:34 +0100 Subject: [PATCH] More socket testing --- Backend/Program.cs | 4 +-- FrontSocket/Program.cs | 4 +++ .../Payload/NotificationPayload.cs | 3 ++- ...ansmission.NotificationPayload.Designer.cs | 26 ++++++++++++++++--- ...ions.Transmission.NotificationPayload.resx | 10 +++++-- Site/Scripts/Swarmops-v5.js | 2 +- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Backend/Program.cs b/Backend/Program.cs index e29bb1ab..86f33fa6 100644 --- a/Backend/Program.cs +++ b/Backend/Program.cs @@ -75,7 +75,7 @@ namespace Swarmops.Backend Console.WriteLine ("Creating OutboundComm..."); - OutboundComm.CreateNotification (null, NotificationResource.System_Startup); + OutboundComm.CreateNotification (null, NotificationResource.System_Startup_Backend); Console.WriteLine ("Transmitting..."); @@ -166,7 +166,7 @@ namespace Swarmops.Backend // Tell sysop we're starting - OutboundComm.CreateNotification (null, NotificationResource.System_Startup); + OutboundComm.CreateNotification (null, NotificationResource.System_Startup_Backend); // Check for existence of installation ID. If not, create one. Warning: has privacy implications when communicated. diff --git a/FrontSocket/Program.cs b/FrontSocket/Program.cs index df60c0be..1b2d4835 100644 --- a/FrontSocket/Program.cs +++ b/FrontSocket/Program.cs @@ -8,6 +8,8 @@ using Mono.Unix; using Mono.Unix.Native; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Communications.Payload; using Swarmops.Logic.ExtensionMethods; using WebSocketSharp.Server; @@ -31,6 +33,8 @@ namespace Swarmops.Frontend.Socket Console.WriteLine(" * Swarmops Frontend Socket Server starting up."); + OutboundComm.CreateNotification(null, NotificationResource.System_Startup_Frontend); + _socketServer = new WebSocketServer (12172); // TODO: Read from database _socketServer.AddWebSocketService ("/Master"); // _socketServer.KeepClean = false; // as per the author's recommendation - this may be bad in the long run diff --git a/Logic/Communications/Payload/NotificationPayload.cs b/Logic/Communications/Payload/NotificationPayload.cs index ab0cd54c..c1ce925c 100644 --- a/Logic/Communications/Payload/NotificationPayload.cs +++ b/Logic/Communications/Payload/NotificationPayload.cs @@ -144,7 +144,8 @@ namespace Swarmops.Logic.Communications.Payload public enum NotificationResource { Unknown = 0, - System_Startup, + System_Startup_Backend, + System_Startup_Frontend, System_Exception, System_DatabaseSchemaUpgraded, System_DatabaseUpgradeFailed, diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs index c6f7da16..d87366a1 100644 --- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs +++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs @@ -846,18 +846,36 @@ namespace Swarmops.Logic.Resources { /// /// Looks up a localized string similar to Swarmops Backend version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks.. /// - internal static string System_Startup_Body { + internal static string System_Startup_Backend_Body { get { - return ResourceManager.GetString("System_Startup_Body", resourceCulture); + return ResourceManager.GetString("System_Startup_Backend_Body", resourceCulture); } } /// /// Looks up a localized string similar to Swarmops Backend operational. /// - internal static string System_Startup_Subject { + internal static string System_Startup_Backend_Subject { get { - return ResourceManager.GetString("System_Startup_Subject", resourceCulture); + return ResourceManager.GetString("System_Startup_Backend_Subject", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Swarmops Frontend socket server version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks.. + /// + internal static string System_Startup_Frontend_Body { + get { + return ResourceManager.GetString("System_Startup_Frontend_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Swarmops Frontend operational. + /// + internal static string System_Startup_Frontend_Subject { + get { + return ResourceManager.GetString("System_Startup_Frontend_Subject", resourceCulture); } } diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx index 1d899baf..51f0fdb5 100644 --- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx +++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx @@ -455,12 +455,18 @@ The upgrade will be retried every hour. Some functionality may be disabled until Swarmops: Hotwallet public root key reset - + Swarmops Backend version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks. - + Swarmops Backend operational + + Swarmops Frontend socket server version [SwarmopsVersion] on host [HostName] has successfully started and connected to database and notification frameworks. + + + Swarmops Frontend operational + The Swarmops transmission engine on [HostName] has encountered an unknown payload type ([UnrecognizedPayloadType]). This should only happen at very rare occasions in conjunction with upgrades where an upgraded version has to take care of something that changed names in the process, itself a rare phenomenon. diff --git a/Site/Scripts/Swarmops-v5.js b/Site/Scripts/Swarmops-v5.js index 2baf37e7..a6435c53 100644 --- a/Site/Scripts/Swarmops-v5.js +++ b/Site/Scripts/Swarmops-v5.js @@ -42,7 +42,7 @@ function _masterInitializeSocket(authenticationTicket) { } function getMasterSocketAddress() { - if (location.host.contains ("localhost")) { // Assume dev environment, go for sandbox socket + if (location.host.includes ("localhost")) { // Assume dev environment, go for sandbox socket return 'ws://sandbox.swarmops.com/ws/Master'; } else { var protocol = ('https:' == document.location.protocol ? 'wss://' : 'ws://');