diff --git a/HaWeb/README.md b/HaWeb/README.md index 0dd78d2..abff1f8 100644 --- a/HaWeb/README.md +++ b/HaWeb/README.md @@ -23,7 +23,7 @@ Note that nodejs is used only as a build tool for css (and possibly in the futur ## Development tools -Run +Set the `DOTNET_ENVIRONMENT` variable to `Development`. Run `dotnet watch run` and @@ -47,6 +47,16 @@ For a Linux server run: `dotnet publish --runtime linux-x64 -c Release` +In the appropriate settings (set the `DOTNET_ENVIRONMENT` variable on the server to `Staging` (development.hamann-ausgabe.de) or `Production` (hamann-ausgabe.de)) set the variables for + +- HamannFileStoreLinux +- WorkingTreePathLinux +- BareRepositoryPathLinux +- RepositoryBranch +- RepositoryURL + +Absolute paths, sadly, are reqired. Create Folders if neccessary. Reading rights are required for `HamannFileStoreLinux` (to save the state). The `BareRepositoryPath` usually is the `.git` Folder inside the Repo, where the Server gets the latest commit information from `refs/heads/`. To sync either you set up a git server and set the server as remote of the repository to push. Or use git webhooks to pull on pushes. + ## Redesign der Hamann-Vebseite, drittes Update Veränderungenen in der Funktionalität für den Benutzer - Behutsames Redesign der Webseite: diff --git a/HaWeb/Views/Shared/_Javascript.cshtml b/HaWeb/Views/Shared/_Javascript.cshtml index 97493a4..3d7425a 100644 --- a/HaWeb/Views/Shared/_Javascript.cshtml +++ b/HaWeb/Views/Shared/_Javascript.cshtml @@ -1,8 +1,5 @@ @* Global Scripts -- These are not inside .cshtml to not loose deferred execution posibility *@ - - - diff --git a/HaWeb/Views/Shared/_Notifications.cshtml b/HaWeb/Views/Shared/_Notifications.cshtml index 73cc403..fe89f6f 100644 --- a/HaWeb/Views/Shared/_Notifications.cshtml +++ b/HaWeb/Views/Shared/_Notifications.cshtml @@ -7,3 +7,4 @@ + \ No newline at end of file diff --git a/HaWeb/WebSockets/WebSocketMiddleware.cs b/HaWeb/WebSockets/WebSocketMiddleware.cs index 85b164b..6858e52 100644 --- a/HaWeb/WebSockets/WebSocketMiddleware.cs +++ b/HaWeb/WebSockets/WebSocketMiddleware.cs @@ -5,6 +5,7 @@ using HaWeb; using HaWeb.FileHelpers; using HaWeb.Models; using HaWeb.XMLParser; +using Microsoft.AspNetCore.Connections; using Microsoft.FeatureManagement; public class WebSocketMiddleware : IMiddleware { @@ -70,16 +71,24 @@ public class WebSocketMiddleware : IMiddleware { WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); while (!result.CloseStatus.HasValue) { var msg = Encoding.UTF8.GetString(buffer,0,result.Count); - if (msg.ToLower() == "hello") { - var state = _xmlProvider.GetGitState(); - await webSocket.SendAsync(_SerializeToBytes(state), WebSocketMessageType.Text, true, CancellationToken.None); - await webSocket.SendAsync(_SerializeToBytes(new FileState(_xmlService.GetState())), WebSocketMessageType.Text, true, CancellationToken.None); - } else if (msg.ToLower() == "ping" ) { - await webSocket.SendAsync(_SerializeToBytes(new { Ping = true}), WebSocketMessageType.Text, true, CancellationToken.None); + try { + if (msg.ToLower() == "hello") { + var state = _xmlProvider.GetGitState(); + await webSocket.SendAsync(_SerializeToBytes(state), WebSocketMessageType.Text, true, CancellationToken.None); + await webSocket.SendAsync(_SerializeToBytes(new FileState(_xmlService.GetState())), WebSocketMessageType.Text, true, CancellationToken.None); + } else if (msg.ToLower() == "ping" ) { + await webSocket.SendAsync(_SerializeToBytes(new { Ping = true}), WebSocketMessageType.Text, true, CancellationToken.None); + } + result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); + } catch (ConnectionAbortedException ex) { + _openSockets!.Remove(webSocket); } - result = await webSocket.ReceiveAsync(new ArraySegment(buffer), CancellationToken.None); } - await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + try { + await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); + } catch (ConnectionAbortedException ex) { + _openSockets.Remove(webSocket); + } _openSockets!.Remove(webSocket); } @@ -116,7 +125,11 @@ public class WebSocketMiddleware : IMiddleware { private async Task _SendToAll(T msg) { if (_openSockets == null) return; foreach (var socket in _openSockets) { - await socket.SendAsync(_SerializeToBytes(msg), WebSocketMessageType.Text, true, CancellationToken.None); + try { + await socket.SendAsync(_SerializeToBytes(msg), WebSocketMessageType.Text, true, CancellationToken.None); + } catch (ConnectionAbortedException ex) { + _openSockets.Remove(socket); + } } } diff --git a/HaWeb/wwwroot/js/websocket.js b/HaWeb/wwwroot/js/websocket.js index 18e3122..34b6c69 100644 --- a/HaWeb/wwwroot/js/websocket.js +++ b/HaWeb/wwwroot/js/websocket.js @@ -28,7 +28,7 @@ socket.onopen = function (event) { socket.send("Hello"); wsPingInterval = setInterval(() => { socket.send("Ping"); - }, 4500); + }, 30000); updateMessage(); }; socket.onclose = function (event) {