From 1f28b8bbfdef5ae4b98d155163f825a2f35d6975 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 25 Mar 2015 18:46:39 +0100 Subject: [PATCH] Added settings for WebSocket ports --- Logic/Support/SystemSettings.cs | 12 ++++++ Site5/App_GlobalResources/Global.resx | 3 ++ Site5/App_GlobalResources/Pages.Admin.resx | 6 +++ .../App_GlobalResources/Pages.Financial.resx | 3 ++ Site5/Pages/v5/Admin/SystemSettings.aspx | 4 ++ Site5/Pages/v5/Admin/SystemSettings.aspx.cs | 43 +++++++++++++++++++ 6 files changed, 71 insertions(+) diff --git a/Logic/Support/SystemSettings.cs b/Logic/Support/SystemSettings.cs index ba14d0af..a73109d6 100644 --- a/Logic/Support/SystemSettings.cs +++ b/Logic/Support/SystemSettings.cs @@ -67,6 +67,18 @@ namespace Swarmops.Logic.Support } } + static public int WebsocketPortServer + { + get { return Int32.Parse(GetDefaultedPersistedKey("WebsocketPortServer", "12172")); } + set { Persistence.Key["WebsocketPortServer"] = value.ToString(CultureInfo.InvariantCulture); } + } + + static public int WebsocketPortClient + { + get { return Int32.Parse(GetDefaultedPersistedKey("WebsocketPortClient", "12172")); } + set { Persistence.Key["WebsocketPortClient"] = value.ToString(CultureInfo.InvariantCulture); } + } + static public string ExternalUrl { get diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index 5ba2b49d..53d5b540 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -660,4 +660,7 @@ Working... + + Unable to connect WebSocket. Live updates will not be available. + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Admin.resx b/Site5/App_GlobalResources/Pages.Admin.resx index 7ef3dee8..2c617720 100644 --- a/Site5/App_GlobalResources/Pages.Admin.resx +++ b/Site5/App_GlobalResources/Pages.Admin.resx @@ -233,4 +233,10 @@ You really, really, REALLY should use HTTPS for a website like this. But you knew that already, didn't you? + + WebSocket Port (Client) + + + WebSocket Port (Server) + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Financial.resx b/Site5/App_GlobalResources/Pages.Financial.resx index 353a574a..45808c3d 100644 --- a/Site5/App_GlobalResources/Pages.Financial.resx +++ b/Site5/App_GlobalResources/Pages.Financial.resx @@ -173,6 +173,9 @@ Invoice #{0:N0} from {1} was UN-attested. It will not be paid unless attested again. When somebody undoes a previous attestation. + + There is not enough funds in the budget to attest this cost. + Attest Costs diff --git a/Site5/Pages/v5/Admin/SystemSettings.aspx b/Site5/Pages/v5/Admin/SystemSettings.aspx index 4053eee3..c444c80c 100644 --- a/Site5/Pages/v5/Admin/SystemSettings.aspx +++ b/Site5/Pages/v5/Admin/SystemSettings.aspx @@ -40,6 +40,8 @@ ​
​
​
+ ​
+ ​
diff --git a/Site5/Pages/v5/Admin/SystemSettings.aspx.cs b/Site5/Pages/v5/Admin/SystemSettings.aspx.cs index 936c6693..0270dca0 100644 --- a/Site5/Pages/v5/Admin/SystemSettings.aspx.cs +++ b/Site5/Pages/v5/Admin/SystemSettings.aspx.cs @@ -36,6 +36,8 @@ namespace Swarmops.Frontend.Pages.v5.Admin this.TextInstallationName.Text = SystemSettings.InstallationName; this.TextAdminAddress.Text = SystemSettings.AdminNotificationAddress; this.TextAdminSender.Text = SystemSettings.AdminNotificationSender; + this.TextWebsocketPortServer.Text = SystemSettings.WebsocketPortServer.ToString(CultureInfo.InvariantCulture); + this.TextWebsocketPortClient.Text = SystemSettings.WebsocketPortClient.ToString(CultureInfo.InvariantCulture); Localize(); } @@ -132,6 +134,8 @@ namespace Swarmops.Frontend.Pages.v5.Admin this.LabelInstallationName.Text = Resources.Pages.Admin.SystemSettings_InstallationName; this.LabelAdminAddress.Text = Resources.Pages.Admin.SystemSettings_AdminAddress; this.LabelAdminSender.Text = Resources.Pages.Admin.SystemSettings_AdminSender; + this.LabelWebsocketPortServer.Text = Resources.Pages.Admin.SystemSettings_WebsocketPortServer; + this.LabelWebsocketPortClient.Text = Resources.Pages.Admin.SystemSettings_WebsocketPortClient; } [WebMethod] @@ -224,6 +228,45 @@ namespace Swarmops.Frontend.Pages.v5.Admin SystemSettings.AdminNotificationAddress = result.NewData; break; + case "WebsocketServer": + try + { + int newPort = Int32.Parse(newValue); + if (newPort < 1 || newPort > 32767) + { + throw new ArgumentException(); + } + result.ResultCode = AjaxTextBox.CodeSuccess; + result.NewData = newValue.Trim(); + SystemSettings.WebsocketPortServer = newPort; + } + catch (Exception) + { + result.ResultCode = AjaxTextBox.CodeInvalid; + result.NewData = SystemSettings.WebsocketPortServer.ToString(CultureInfo.InvariantCulture); + } + break; + + case "WebsocketClient": + try + { + int newPort = Int32.Parse(newValue); + if (newPort < 1 || newPort > 32767) + { + throw new ArgumentException(); + } + + result.ResultCode = AjaxTextBox.CodeSuccess; + result.NewData = newValue.Trim(); + SystemSettings.WebsocketPortClient = newPort; + } + catch (Exception) + { + result.ResultCode = AjaxTextBox.CodeInvalid; + result.NewData = SystemSettings.WebsocketPortClient.ToString(CultureInfo.InvariantCulture); + } + break; + default: throw new NotImplementedException("Unknown cookie in StoreCallback"); }