From af1d009f327a0fb64de4856477f0a1466b3d67b4 Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Thu, 22 Jan 2026 11:13:20 -0700 Subject: [PATCH 01/13] chore: updating to .net 10 --- .../Models/DisplayRepository.cs | 2 +- .../Models/RelayRepository.cs | 3 +- .../Properties/launchSettings.json | 36 ++++++++++++------- .../SpyderTallyControllerWebApp.csproj | 3 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/SpyderTallyControllerWebApp/Models/DisplayRepository.cs b/src/SpyderTallyControllerWebApp/Models/DisplayRepository.cs index 3954026..21d3503 100644 --- a/src/SpyderTallyControllerWebApp/Models/DisplayRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/DisplayRepository.cs @@ -43,7 +43,7 @@ public DisplayRepository(IRelayRepository relayRepository) backlightPin: 3, backlightBrightness: 0.1f, readWritePin: 1, - controller: new GpioController(PinNumberingScheme.Logical, driver)); + controller: new GpioController(driver) /* PinNumberingScheme.Logical */); } catch(Exception ex) { diff --git a/src/SpyderTallyControllerWebApp/Models/RelayRepository.cs b/src/SpyderTallyControllerWebApp/Models/RelayRepository.cs index d2af692..f43e4e7 100644 --- a/src/SpyderTallyControllerWebApp/Models/RelayRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/RelayRepository.cs @@ -66,7 +66,8 @@ public void SetRelayStatus(int relayIndex, bool value) if(deviceConfiguration.TallyGpioPinAssignments.TryGetValue(relayIndex, out int pinAssignment)) { //Write hardware - gpioController.Write(pinAssignment, value ? PinValue.High : PinValue.Low); + if(gpioController != null) + gpioController.Write(pinAssignment, value ? PinValue.High : PinValue.Low); //Update internal state and fire event relayStatus[relayIndex] = value; diff --git a/src/SpyderTallyControllerWebApp/Properties/launchSettings.json b/src/SpyderTallyControllerWebApp/Properties/launchSettings.json index 0e14b75..3e80763 100644 --- a/src/SpyderTallyControllerWebApp/Properties/launchSettings.json +++ b/src/SpyderTallyControllerWebApp/Properties/launchSettings.json @@ -1,21 +1,13 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55543", - "sslPort": 44383 - } - }, +{ "profiles": { "SpyderTallyControllerWebApp": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7253;http://localhost:5253", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7253;http://localhost:5253" }, "IIS Express": { "commandName": "IISExpress", @@ -23,6 +15,24 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "WSL": { + "commandName": "WSL2", + "launchBrowser": true, + "launchUrl": "https://localhost:7253", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:7253;http://localhost:5253" + }, + "distributionName": "" + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:55543", + "sslPort": 44383 } } -} +} \ No newline at end of file diff --git a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj index df7aea3..fd13c27 100644 --- a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj +++ b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj @@ -1,10 +1,11 @@ - net7.0 + net10.0 disable enable 1.0.1 + 8a5e8aab-906e-4fba-b610-4fc17b1f8b66 From 02a9209752bbf1b161844f673bfd93ebcfcd017c Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Thu, 22 Jan 2026 12:37:06 -0700 Subject: [PATCH 02/13] feat: adding SignalR push to the status page for current tally status --- .../Hubs/TallyHub.cs | 25 +++++++++++++ src/SpyderTallyControllerWebApp/Program.cs | 6 ++++ .../Services/TallyStatusBroadcaster.cs | 36 +++++++++++++++++++ .../Views/Home/Index.cshtml | 26 ++++++++++++-- .../Views/Shared/_Layout.cshtml | 3 +- 5 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 src/SpyderTallyControllerWebApp/Hubs/TallyHub.cs create mode 100644 src/SpyderTallyControllerWebApp/Services/TallyStatusBroadcaster.cs diff --git a/src/SpyderTallyControllerWebApp/Hubs/TallyHub.cs b/src/SpyderTallyControllerWebApp/Hubs/TallyHub.cs new file mode 100644 index 0000000..bbe8df1 --- /dev/null +++ b/src/SpyderTallyControllerWebApp/Hubs/TallyHub.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.SignalR; +using SpyderTallyControllerWebApp.Models; + +namespace SpyderTallyControllerWebApp.Hubs +{ + public class TallyHub : Hub + { + public const string TallyStatusUpdatedMessage = "TallyStatusUpdated"; + + private readonly IRelayRepository _relayRepository; + + public TallyHub(IRelayRepository relayRepository) + { + _relayRepository = relayRepository; + } + + public override async Task OnConnectedAsync() + { + // Send current tally status to newly connected clients + var currentStatus = _relayRepository.GetRelayStatus(); + await Clients.Caller.SendAsync(TallyStatusUpdatedMessage, currentStatus); + await base.OnConnectedAsync(); + } + } +} diff --git a/src/SpyderTallyControllerWebApp/Program.cs b/src/SpyderTallyControllerWebApp/Program.cs index f316f5f..e37d176 100644 --- a/src/SpyderTallyControllerWebApp/Program.cs +++ b/src/SpyderTallyControllerWebApp/Program.cs @@ -1,5 +1,7 @@ using SpyderTallyControllerWebApp; +using SpyderTallyControllerWebApp.Hubs; using SpyderTallyControllerWebApp.Models; +using SpyderTallyControllerWebApp.Services; var spyderManager = new Spyder.Client.SpyderClientManager(); spyderManager.ServerListChanged += async (s, e) => @@ -25,6 +27,8 @@ // Add services to the container. builder.Services.AddControllersWithViews(); +builder.Services.AddSignalR(); +builder.Services.AddHostedService(); var app = builder.Build(); @@ -51,4 +55,6 @@ name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); +app.MapHub("/tallyHub"); + app.Run(); diff --git a/src/SpyderTallyControllerWebApp/Services/TallyStatusBroadcaster.cs b/src/SpyderTallyControllerWebApp/Services/TallyStatusBroadcaster.cs new file mode 100644 index 0000000..8d6113d --- /dev/null +++ b/src/SpyderTallyControllerWebApp/Services/TallyStatusBroadcaster.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.SignalR; +using SpyderTallyControllerWebApp.Hubs; +using SpyderTallyControllerWebApp.Models; + +namespace SpyderTallyControllerWebApp.Services +{ + public class TallyStatusBroadcaster : IHostedService + { + private readonly IRelayRepository _relayRepository; + private readonly IHubContext _hubContext; + + public TallyStatusBroadcaster(IRelayRepository relayRepository, IHubContext hubContext) + { + _relayRepository = relayRepository; + _hubContext = hubContext; + } + + public Task StartAsync(CancellationToken cancellationToken) + { + _relayRepository.RelayStatusChanged += OnRelayStatusChanged; + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken) + { + _relayRepository.RelayStatusChanged -= OnRelayStatusChanged; + return Task.CompletedTask; + } + + private async void OnRelayStatusChanged(object sender, EventArgs e) + { + var currentStatus = _relayRepository.GetRelayStatus(); + await _hubContext.Clients.All.SendAsync(TallyHub.TallyStatusUpdatedMessage, currentStatus); + } + } +} diff --git a/src/SpyderTallyControllerWebApp/Views/Home/Index.cshtml b/src/SpyderTallyControllerWebApp/Views/Home/Index.cshtml index 8b869da..e49a011 100644 --- a/src/SpyderTallyControllerWebApp/Views/Home/Index.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Home/Index.cshtml @@ -7,9 +7,9 @@

Current Status

- @foreach (bool tallyStatus in Model.CurrentTallyStatus) + @for (int i = 0; i < Model.CurrentTallyStatus.Length; i++) { - + }
@@ -24,3 +24,25 @@
Disk: @Model.DiskUsage
HW Model: @Model.Model
+ +@section Scripts { + +} diff --git a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml index ac3bef8..94a703e 100644 --- a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml @@ -38,11 +38,12 @@ + @await RenderSectionAsync("Scripts", required: false) From 74b455ac569ed221b611bc2bbf4051846197d6ed Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Thu, 22 Jan 2026 12:44:11 -0700 Subject: [PATCH 03/13] feat: dark mode support! --- .../SpyderTallyControllerWebApp.csproj | 10 +- .../Views/Configuration/Index.cshtml | 30 ++++++ .../Views/Shared/_Layout.cshtml | 6 ++ .../wwwroot/css/site.css | 98 +++++++++++++++++++ 4 files changed, 140 insertions(+), 4 deletions(-) diff --git a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj index fd13c27..5e87d47 100644 --- a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj +++ b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj @@ -13,14 +13,16 @@
- - - - + + + + + +
diff --git a/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml b/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml index edb46ef..df0d3cf 100644 --- a/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml @@ -60,3 +60,33 @@ + +
+

Display Settings

+
+ + +
+
+ +@section Scripts { + +} diff --git a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml index 94a703e..4fd71fd 100644 --- a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml @@ -4,6 +4,12 @@ @ViewData["Title"] - Spyder Tallies + diff --git a/src/SpyderTallyControllerWebApp/wwwroot/css/site.css b/src/SpyderTallyControllerWebApp/wwwroot/css/site.css index 50d5b60..6381322 100644 --- a/src/SpyderTallyControllerWebApp/wwwroot/css/site.css +++ b/src/SpyderTallyControllerWebApp/wwwroot/css/site.css @@ -15,4 +15,102 @@ html { body { margin-bottom: 60px; +} + +/* Dark mode styles */ +[data-theme="dark"] { + background-color: #1a1a1a; + color: #e0e0e0; +} + +[data-theme="dark"] body { + background-color: #1a1a1a; + color: #e0e0e0; +} + +[data-theme="dark"] .navbar { + background-color: #2d2d2d !important; + border-color: #404040 !important; +} + +[data-theme="dark"] .navbar-brand, +[data-theme="dark"] .nav-link { + color: #e0e0e0 !important; +} + +[data-theme="dark"] .nav-link:hover { + color: #ffffff !important; +} + +[data-theme="dark"] .footer { + background-color: #2d2d2d; + border-color: #404040 !important; + color: #e0e0e0; +} + +[data-theme="dark"] .form-control { + background-color: #2d2d2d; + border-color: #404040; + color: #e0e0e0; +} + +[data-theme="dark"] .form-control:focus { + background-color: #3d3d3d; + border-color: #0d6efd; + color: #e0e0e0; +} + +[data-theme="dark"] select.form-control { + background-color: #2d2d2d; + color: #e0e0e0; +} + +[data-theme="dark"] table { + color: #e0e0e0; +} + +[data-theme="dark"] a { + color: #6ea8fe; +} + +[data-theme="dark"] a:hover { + color: #9ec5fe; +} + +/* Dark mode toggle switch styling */ +.theme-switch { + display: flex; + align-items: center; + gap: 10px; +} + +.theme-switch input[type="checkbox"] { + width: 50px; + height: 26px; + appearance: none; + background-color: #ccc; + border-radius: 13px; + position: relative; + cursor: pointer; + transition: background-color 0.3s; +} + +.theme-switch input[type="checkbox"]:checked { + background-color: #0d6efd; +} + +.theme-switch input[type="checkbox"]::before { + content: ""; + position: absolute; + width: 22px; + height: 22px; + border-radius: 50%; + background-color: white; + top: 2px; + left: 2px; + transition: transform 0.3s; +} + +.theme-switch input[type="checkbox"]:checked::before { + transform: translateX(24px); } \ No newline at end of file From dea8d2f7d67b6451ad1895c7b7f12d674a39cbf3 Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Thu, 22 Jan 2026 12:56:12 -0700 Subject: [PATCH 04/13] fix: embedding the SignalR package for async updates In a prior update I added SignalR, but I was using Cloudflare's CDN which won't be available if we're running on device in a network with no internet, which I think is very likely. Also updated the date footer to show the current year --- src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml | 4 ++-- src/SpyderTallyControllerWebApp/wwwroot/css/site.css | 6 ++++++ .../wwwroot/lib/signalr/signalr.min.js | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/SpyderTallyControllerWebApp/wwwroot/lib/signalr/signalr.min.js diff --git a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml index 4fd71fd..a9d761e 100644 --- a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml @@ -44,12 +44,12 @@
- © 2026 - Knightware - Privacy + © @DateTime.Now.Year - Knightware - Privacy
- + @await RenderSectionAsync("Scripts", required: false) diff --git a/src/SpyderTallyControllerWebApp/wwwroot/css/site.css b/src/SpyderTallyControllerWebApp/wwwroot/css/site.css index 6381322..ff9a677 100644 --- a/src/SpyderTallyControllerWebApp/wwwroot/css/site.css +++ b/src/SpyderTallyControllerWebApp/wwwroot/css/site.css @@ -113,4 +113,10 @@ body { .theme-switch input[type="checkbox"]:checked::before { transform: translateX(24px); +} + +/* Configuration page form spacing */ +table tbody td { + padding-top: 6px; + padding-bottom: 6px; } \ No newline at end of file diff --git a/src/SpyderTallyControllerWebApp/wwwroot/lib/signalr/signalr.min.js b/src/SpyderTallyControllerWebApp/wwwroot/lib/signalr/signalr.min.js new file mode 100644 index 0000000..e4e442f --- /dev/null +++ b/src/SpyderTallyControllerWebApp/wwwroot/lib/signalr/signalr.min.js @@ -0,0 +1,2 @@ +var t,e;t=self,e=()=>(()=>{var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var e,s={};t.r(s),t.d(s,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>i,HttpResponse:()=>u,HttpTransportType:()=>F,HubConnection:()=>q,HubConnectionBuilder:()=>tt,HubConnectionState:()=>A,JsonHubProtocol:()=>Y,LogLevel:()=>e,MessageType:()=>x,NullLogger:()=>f,Subject:()=>U,TimeoutError:()=>n,TransferFormat:()=>B,VERSION:()=>p});class i extends Error{constructor(t,e){const s=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=s}}class n extends Error{constructor(t="A timeout occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class r extends Error{constructor(t="An abort occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class o extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=s}}class h extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=s}}class c extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=s}}class a extends Error{constructor(t){const e=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=e}}class l extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=s}}class u{constructor(t,e,s){this.statusCode=t,this.statusText=e,this.content=s}}class d{get(t,e){return this.send({...e,method:"GET",url:t})}post(t,e){return this.send({...e,method:"POST",url:t})}delete(t,e){return this.send({...e,method:"DELETE",url:t})}getCookieString(t){return""}}!function(t){t[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"}(e||(e={}));class f{constructor(){}log(t,e){}}f.instance=new f;const p="8.0.0";class w{static isRequired(t,e){if(null==t)throw new Error(`The '${e}' argument is required.`)}static isNotEmpty(t,e){if(!t||t.match(/^\s*$/))throw new Error(`The '${e}' argument should not be empty.`)}static isIn(t,e,s){if(!(t in e))throw new Error(`Unknown ${s} value: ${t}.`)}}class g{static get isBrowser(){return!g.isNode&&"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return!g.isNode&&"object"==typeof self&&"importScripts"in self}static get isReactNative(){return!g.isNode&&"object"==typeof window&&void 0===window.document}static get isNode(){return"undefined"!=typeof process&&process.release&&"node"===process.release.name}}function m(t,e){let s="";return y(t)?(s=`Binary data of length ${t.byteLength}`,e&&(s+=`. Content: '${function(t){const e=new Uint8Array(t);let s="";return e.forEach((t=>{s+=`0x${t<16?"0":""}${t.toString(16)} `})),s.substr(0,s.length-1)}(t)}'`)):"string"==typeof t&&(s=`String data of length ${t.length}`,e&&(s+=`. Content: '${t}'`)),s}function y(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,s,i,n,r,o){const h={},[c,a]=$();h[c]=a,t.log(e.Trace,`(${s} transport) sending data. ${m(r,o.logMessageContent)}.`);const l=y(r)?"arraybuffer":"text",u=await i.post(n,{content:r,headers:{...h,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});t.log(e.Trace,`(${s} transport) request complete. Response status: ${u.statusCode}.`)}class v{constructor(t,e){this.i=t,this.h=e}dispose(){const t=this.i.observers.indexOf(this.h);t>-1&&this.i.observers.splice(t,1),0===this.i.observers.length&&this.i.cancelCallback&&this.i.cancelCallback().catch((t=>{}))}}class E{constructor(t){this.l=t,this.out=console}log(t,s){if(t>=this.l){const i=`[${(new Date).toISOString()}] ${e[t]}: ${s}`;switch(t){case e.Critical:case e.Error:this.out.error(i);break;case e.Warning:this.out.warn(i);break;case e.Information:this.out.info(i);break;default:this.out.log(i)}}}}function $(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(p,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,s,i){let n="Microsoft SignalR/";const r=t.split(".");return n+=`${r[0]}.${r[1]}`,n+=` (${t}; `,n+=e&&""!==e?`${e}; `:"Unknown OS; ",n+=`${s}`,n+=i?`; ${i}`:"; Unknown Runtime Version",n+=")",n}function S(){if(!g.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function k(){if(g.isNode)return process.versions.node}function P(t){return t.stack?t.stack:t.message?t.message:`${t}`}class T extends d{constructor(e){super(),this.u=e,this.p=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t.g)return t.g;throw new Error("could not find global")}()),this.m=AbortController,this.m}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new r;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const s=new this.m;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{s.abort(),o=new r});let h,c=null;if(t.timeout){const i=t.timeout;c=setTimeout((()=>{s.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new n}),i)}""===t.content&&(t.content=void 0),t.content&&(t.headers=t.headers||{},y(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");try{h=await this.p(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:s.signal})}catch(t){if(o)throw o;throw this.u.log(e.Warning,`Error from HTTP request. ${t}.`),t}finally{c&&clearTimeout(c),t.abortSignal&&(t.abortSignal.onabort=null)}if(!h.ok){const t=await I(h,"text");throw new i(t||h.statusText,h.status)}const a=I(h,t.responseType),l=await a;return new u(h.status,h.statusText,l)}getCookieString(t){let e="";return g.isNode&&this.v&&this.v.getCookies(t,((t,s)=>e=s.join("; "))),e}}function I(t,e){let s;switch(e){case"arraybuffer":s=t.arrayBuffer();break;case"text":default:s=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`)}return s}class _ extends d{constructor(t){super(),this.u=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?new Promise(((s,o)=>{const h=new XMLHttpRequest;h.open(t.method,t.url,!0),h.withCredentials=void 0===t.withCredentials||t.withCredentials,h.setRequestHeader("X-Requested-With","XMLHttpRequest"),""===t.content&&(t.content=void 0),t.content&&(y(t.content)?h.setRequestHeader("Content-Type","application/octet-stream"):h.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const c=t.headers;c&&Object.keys(c).forEach((t=>{h.setRequestHeader(t,c[t])})),t.responseType&&(h.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{h.abort(),o(new r)}),t.timeout&&(h.timeout=t.timeout),h.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),h.status>=200&&h.status<300?s(new u(h.status,h.statusText,h.response||h.responseText)):o(new i(h.response||h.responseText||h.statusText,h.status))},h.onerror=()=>{this.u.log(e.Warning,`Error from HTTP request. ${h.status}: ${h.statusText}.`),o(new i(h.statusText,h.status))},h.ontimeout=()=>{this.u.log(e.Warning,"Timeout from HTTP request."),o(new n)},h.send(t.content)})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class H extends d{constructor(t){if(super(),"undefined"!=typeof fetch||g.isNode)this.$=new T(t);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this.$=new _(t)}}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?this.$.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this.$.getCookieString(t)}}class D{static write(t){return`${t}${D.RecordSeparator}`}static parse(t){if(t[t.length-1]!==D.RecordSeparator)throw new Error("Message is incomplete.");const e=t.split(D.RecordSeparator);return e.pop(),e}}D.RecordSeparatorCode=30,D.RecordSeparator=String.fromCharCode(D.RecordSeparatorCode);class R{writeHandshakeRequest(t){return D.write(JSON.stringify(t))}parseHandshakeResponse(t){let e,s;if(y(t)){const i=new Uint8Array(t),n=i.indexOf(D.RecordSeparatorCode);if(-1===n)throw new Error("Message is incomplete.");const r=n+1;e=String.fromCharCode.apply(null,Array.prototype.slice.call(i.slice(0,r))),s=i.byteLength>r?i.slice(r).buffer:null}else{const i=t,n=i.indexOf(D.RecordSeparator);if(-1===n)throw new Error("Message is incomplete.");const r=n+1;e=i.substring(0,r),s=i.length>r?i.substring(r):null}const i=D.parse(e),n=JSON.parse(i[0]);if(n.type)throw new Error("Expected a handshake response from the server.");return[s,n]}}var x,A;!function(t){t[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close",t[t.Ack=8]="Ack",t[t.Sequence=9]="Sequence"}(x||(x={}));class U{constructor(){this.observers=[]}next(t){for(const e of this.observers)e.next(t)}error(t){for(const e of this.observers)e.error&&e.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new v(this,t)}}class L{constructor(t,e,s){this.C=1e5,this.S=[],this.k=0,this.P=!1,this.T=1,this.I=0,this._=0,this.H=!1,this.D=t,this.R=e,this.C=s}async A(t){const e=this.D.writeMessage(t);let s=Promise.resolve();if(this.U(t)){this.k++;let t=()=>{},i=()=>{};y(e)?this._+=e.byteLength:this._+=e.length,this._>=this.C&&(s=new Promise(((e,s)=>{t=e,i=s}))),this.S.push(new N(e,this.k,t,i))}try{this.H||await this.R.send(e)}catch{this.L()}await s}N(t){let e=-1;for(let s=0;sthis.T?this.R.stop(new Error("Sequence ID greater than amount of messages we've received.")):this.T=t.sequenceId}L(){this.H=!0,this.P=!0}async B(){const t=0!==this.S.length?this.S[0].q:this.k+1;await this.R.send(this.D.writeMessage({type:x.Sequence,sequenceId:t}));const e=this.S;for(const t of e)await this.R.send(t.M);this.H=!1}X(t){null!=t||(t=new Error("Unable to reconnect to server."));for(const e of this.S)e.J(t)}U(t){switch(t.type){case x.Invocation:case x.StreamItem:case x.Completion:case x.StreamInvocation:case x.CancelInvocation:return!0;case x.Close:case x.Sequence:case x.Ping:case x.Ack:return!1}}O(){void 0===this.V&&(this.V=setTimeout((async()=>{try{this.H||await this.R.send(this.D.writeMessage({type:x.Ack,sequenceId:this.I}))}catch{}clearTimeout(this.V),this.V=void 0}),1e3))}}class N{constructor(t,e,s,i){this.M=t,this.q=e,this.j=s,this.J=i}}!function(t){t.Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting"}(A||(A={}));class q{static create(t,e,s,i,n,r,o){return new q(t,e,s,i,n,r,o)}constructor(t,s,i,n,r,o,h){this.K=0,this.G=()=>{this.u.log(e.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(s,"logger"),w.isRequired(i,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=o?o:15e3,this.Y=null!=h?h:1e5,this.u=s,this.D=i,this.connection=t,this.Z=n,this.tt=new R,this.connection.onreceive=t=>this.et(t),this.connection.onclose=t=>this.st(t),this.it={},this.nt={},this.rt=[],this.ot=[],this.ht=[],this.ct=0,this.lt=!1,this.ut=A.Disconnected,this.dt=!1,this.ft=this.D.writeMessage({type:x.Ping})}get state(){return this.ut}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this.ut!==A.Disconnected&&this.ut!==A.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this.wt=this.gt(),this.wt}async gt(){if(this.ut!==A.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this.ut=A.Connecting,this.u.log(e.Debug,"Starting HubConnection.");try{await this.yt(),g.isBrowser&&window.document.addEventListener("freeze",this.G),this.ut=A.Connected,this.dt=!0,this.u.log(e.Debug,"HubConnection connected successfully.")}catch(t){return this.ut=A.Disconnected,this.u.log(e.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async yt(){this.bt=void 0,this.lt=!1;const t=new Promise(((t,e)=>{this.vt=t,this.Et=e}));await this.connection.start(this.D.transferFormat);try{let s=this.D.version;this.connection.features.reconnect||(s=1);const i={protocol:this.D.name,version:s};if(this.u.log(e.Debug,"Sending handshake request."),await this.$t(this.tt.writeHandshakeRequest(i)),this.u.log(e.Information,`Using HubProtocol '${this.D.name}'.`),this.Ct(),this.St(),this.kt(),await t,this.bt)throw this.bt;!!this.connection.features.reconnect&&(this.Pt=new L(this.D,this.connection,this.Y),this.connection.features.disconnected=this.Pt.L.bind(this.Pt),this.connection.features.resend=()=>{if(this.Pt)return this.Pt.B()}),this.connection.features.inherentKeepAlive||await this.$t(this.ft)}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.Ct(),this.Tt(),await this.connection.stop(t),t}}async stop(){const t=this.wt;this.connection.features.reconnect=!1,this.It=this._t(),await this.It;try{await t}catch(t){}}_t(t){if(this.ut===A.Disconnected)return this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this.ut===A.Disconnecting)return this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.It;const s=this.ut;return this.ut=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.Ht?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.Ht),this.Ht=void 0,this.Dt(),Promise.resolve()):(s===A.Connected&&this.Rt(),this.Ct(),this.Tt(),this.bt=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async Rt(){try{await this.xt(this.At())}catch{}}stream(t,...e){const[s,i]=this.Ut(e),n=this.Lt(t,e,i);let r;const o=new U;return o.cancelCallback=()=>{const t=this.Nt(n.invocationId);return delete this.it[n.invocationId],r.then((()=>this.xt(t)))},this.it[n.invocationId]=(t,e)=>{e?o.error(e):t&&(t.type===x.Completion?t.error?o.error(new Error(t.error)):o.complete():o.next(t.item))},r=this.xt(n).catch((t=>{o.error(t),delete this.it[n.invocationId]})),this.qt(s,r),o}$t(t){return this.kt(),this.connection.send(t)}xt(t){return this.Pt?this.Pt.A(t):this.$t(this.D.writeMessage(t))}send(t,...e){const[s,i]=this.Ut(e),n=this.xt(this.Mt(t,e,!0,i));return this.qt(s,n),n}invoke(t,...e){const[s,i]=this.Ut(e),n=this.Mt(t,e,!1,i);return new Promise(((t,e)=>{this.it[n.invocationId]=(s,i)=>{i?e(i):s&&(s.type===x.Completion?s.error?e(new Error(s.error)):t(s.result):e(new Error(`Unexpected message type: ${s.type}`)))};const i=this.xt(n).catch((t=>{e(t),delete this.it[n.invocationId]}));this.qt(s,i)}))}on(t,e){t&&e&&(t=t.toLowerCase(),this.nt[t]||(this.nt[t]=[]),-1===this.nt[t].indexOf(e)&&this.nt[t].push(e))}off(t,e){if(!t)return;t=t.toLowerCase();const s=this.nt[t];if(s)if(e){const i=s.indexOf(e);-1!==i&&(s.splice(i,1),0===s.length&&delete this.nt[t])}else delete this.nt[t]}onclose(t){t&&this.rt.push(t)}onreconnecting(t){t&&this.ot.push(t)}onreconnected(t){t&&this.ht.push(t)}et(t){if(this.Ct(),this.lt||(t=this.jt(t),this.lt=!0),t){const s=this.D.parseMessages(t,this.u);for(const t of s)if(!this.Pt||this.Pt.W(t))switch(t.type){case x.Invocation:this.Wt(t);break;case x.StreamItem:case x.Completion:{const s=this.it[t.invocationId];if(s){t.type===x.Completion&&delete this.it[t.invocationId];try{s(t)}catch(t){this.u.log(e.Error,`Stream callback threw error: ${P(t)}`)}}break}case x.Ping:break;case x.Close:{this.u.log(e.Information,"Close message received from server.");const s=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(s):this.It=this._t(s);break}case x.Ack:this.Pt&&this.Pt.N(t);break;case x.Sequence:this.Pt&&this.Pt.F(t);break;default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.St()}jt(t){let s,i;try{[i,s]=this.tt.parseHandshakeResponse(t)}catch(t){const s="Error parsing handshake response: "+t;this.u.log(e.Error,s);const i=new Error(s);throw this.Et(i),i}if(s.error){const t="Server returned handshake error: "+s.error;this.u.log(e.Error,t);const i=new Error(t);throw this.Et(i),i}return this.u.log(e.Debug,"Server handshake complete."),this.vt(),i}kt(){this.connection.features.inherentKeepAlive||(this.K=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Tt())}St(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.Ot=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.Ft))){let t=this.K-(new Date).getTime();t<0&&(t=0),this.Ft=setTimeout((async()=>{if(this.ut===A.Connected)try{await this.$t(this.ft)}catch{this.Tt()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async Wt(t){const s=t.target.toLowerCase(),i=this.nt[s];if(!i)return this.u.log(e.Warning,`No client method with the name '${s}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),await this.xt(this.Bt(t.invocationId,"Client didn't provide a result.",null))));const n=i.slice(),r=!!t.invocationId;let o,h,c;for(const i of n)try{const n=o;o=await i.apply(this,t.arguments),r&&o&&n&&(this.u.log(e.Error,`Multiple results provided for '${s}'. Sending error to server.`),c=this.Bt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${s}' threw error '${t}'.`)}c?await this.xt(c):r?(h?c=this.Bt(t.invocationId,`${h}`,null):void 0!==o?c=this.Bt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),c=this.Bt(t.invocationId,"Client didn't provide a result.",null)),await this.xt(c)):o&&this.u.log(e.Error,`Result given for '${s}' method but server is not expecting a result.`)}st(t){this.u.log(e.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this.ut}.`),this.bt=this.bt||t||new r("The underlying connection was closed before the hub handshake could complete."),this.vt&&this.vt(),this.Xt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.Ct(),this.Tt(),this.ut===A.Disconnecting?this.Dt(t):this.ut===A.Connected&&this.Z?this.Jt(t):this.ut===A.Connected&&this.Dt(t)}Dt(t){if(this.dt){this.ut=A.Disconnected,this.dt=!1,this.Pt&&(this.Pt.X(null!=t?t:new Error("Connection closed.")),this.Pt=void 0),g.isBrowser&&window.document.removeEventListener("freeze",this.G);try{this.rt.forEach((e=>e.apply(this,[t])))}catch(s){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${s}'.`)}}}async Jt(t){const s=Date.now();let i=0,n=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.zt(i++,0,n);if(null===r)return this.u.log(e.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this.Dt(t);if(this.ut=A.Reconnecting,t?this.u.log(e.Information,`Connection reconnecting because of error '${t}'.`):this.u.log(e.Information,"Connection reconnecting."),0!==this.ot.length){try{this.ot.forEach((e=>e.apply(this,[t])))}catch(s){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${s}'.`)}if(this.ut!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this.u.log(e.Information,`Reconnect attempt number ${i} will start in ${r} ms.`),await new Promise((t=>{this.Ht=setTimeout(t,r)})),this.Ht=void 0,this.ut!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this.yt(),this.ut=A.Connected,this.u.log(e.Information,"HubConnection reconnected successfully."),0!==this.ht.length)try{this.ht.forEach((t=>t.apply(this,[this.connection.connectionId])))}catch(t){this.u.log(e.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${t}'.`)}return}catch(t){if(this.u.log(e.Information,`Reconnect attempt failed because of error '${t}'.`),this.ut!==A.Reconnecting)return this.u.log(e.Debug,`Connection moved to the '${this.ut}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this.ut===A.Disconnecting&&this.Dt());n=t instanceof Error?t:new Error(t.toString()),r=this.zt(i++,Date.now()-s,n)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-s} ms and ${i} failed attempts. Connection disconnecting.`),this.Dt()}zt(t,s,i){try{return this.Z.nextRetryDelayInMilliseconds({elapsedMilliseconds:s,previousRetryCount:t,retryReason:i})}catch(i){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${s}) threw error '${i}'.`),null}}Xt(t){const s=this.it;this.it={},Object.keys(s).forEach((i=>{const n=s[i];try{n(null,t)}catch(s){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(s)}`)}}))}Tt(){this.Ft&&(clearTimeout(this.Ft),this.Ft=void 0)}Ct(){this.Ot&&clearTimeout(this.Ot)}Mt(t,e,s,i){if(s)return 0!==i.length?{arguments:e,streamIds:i,target:t,type:x.Invocation}:{arguments:e,target:t,type:x.Invocation};{const s=this.ct;return this.ct++,0!==i.length?{arguments:e,invocationId:s.toString(),streamIds:i,target:t,type:x.Invocation}:{arguments:e,invocationId:s.toString(),target:t,type:x.Invocation}}}qt(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const s in t)t[s].subscribe({complete:()=>{e=e.then((()=>this.xt(this.Bt(s))))},error:t=>{let i;i=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.xt(this.Bt(s,i))))},next:t=>{e=e.then((()=>this.xt(this.Vt(s,t))))}})}}Ut(t){const e=[],s=[];for(let i=0;i0)&&(e=!1,this.Zt=await this.Yt()),this.te(t);const s=await this.Qt.send(t);return e&&401===s.statusCode&&this.Yt?(this.Zt=await this.Yt(),this.te(t),await this.Qt.send(t)):s}te(t){t.headers||(t.headers={}),this.Zt?t.headers[W.Authorization]=`Bearer ${this.Zt}`:this.Yt&&t.headers[W.Authorization]&&delete t.headers[W.Authorization]}getCookieString(t){return this.Qt.getCookieString(t)}}var F,B;!function(t){t[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling"}(F||(F={})),function(t){t[t.Text=1]="Text",t[t.Binary=2]="Binary"}(B||(B={}));class X{constructor(){this.ee=!1,this.onabort=null}abort(){this.ee||(this.ee=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.ee}}class J{get pollAborted(){return this.se.aborted}constructor(t,e,s){this.$=t,this.u=e,this.se=new X,this.ie=s,this.ne=!1,this.onreceive=null,this.onclose=null}async connect(t,s){if(w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,B,"transferFormat"),this.re=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),s===B.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[n,r]=$(),o={[n]:r,...this.ie.headers},h={abortSignal:this.se.signal,headers:o,timeout:1e5,withCredentials:this.ie.withCredentials};s===B.Binary&&(h.responseType="arraybuffer");const c=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this.$.get(c,h);200!==a.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this.oe=new i(a.statusText||"",a.statusCode),this.ne=!1):this.ne=!0,this.he=this.ce(this.re,h)}async ce(t,s){try{for(;this.ne;)try{const n=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${n}.`);const r=await this.$.get(n,s);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.ne=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.oe=new i(r.statusText||"",r.statusCode),this.ne=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${m(r.content,this.ie.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.ne?t instanceof n?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.oe=t,this.ne=!1):this.u.log(e.Trace,`(LongPolling transport) Poll errored after shutdown: ${t.message}`)}}finally{this.u.log(e.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.ae()}}async send(t){return this.ne?b(this.u,"LongPolling",this.$,this.re,t,this.ie):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.ne=!1,this.se.abort();try{await this.he,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this.re}.`);const t={},[s,n]=$();t[s]=n;const r={headers:{...t,...this.ie.headers},timeout:this.ie.timeout,withCredentials:this.ie.withCredentials};let o;try{await this.$.delete(this.re,r)}catch(t){o=t}o?o instanceof i&&(404===o.statusCode?this.u.log(e.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this.u.log(e.Trace,`(LongPolling transport) Error sending a DELETE request: ${o}`)):this.u.log(e.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.ae()}}ae(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.oe&&(t+=" Error: "+this.oe),this.u.log(e.Trace,t),this.onclose(this.oe)}}}class z{constructor(t,e,s,i){this.$=t,this.Zt=e,this.u=s,this.ie=i,this.onreceive=null,this.onclose=null}async connect(t,s){return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,B,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this.re=t,this.Zt&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this.Zt)}`),new Promise(((i,n)=>{let r,o=!1;if(s===B.Text){if(g.isBrowser||g.isWebWorker)r=new this.ie.EventSource(t,{withCredentials:this.ie.withCredentials});else{const e=this.$.getCookieString(t),s={};s.Cookie=e;const[i,n]=$();s[i]=n,r=new this.ie.EventSource(t,{withCredentials:this.ie.withCredentials,headers:{...s,...this.ie.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${m(t.data,this.ie.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.le(t)}},r.onerror=t=>{o?this.le():n(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},r.onopen=()=>{this.u.log(e.Information,`SSE connected to ${this.re}`),this.ue=r,o=!0,i()}}catch(t){return void n(t)}}else n(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(t){return this.ue?b(this.u,"SSE",this.$,this.re,t,this.ie):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.le(),Promise.resolve()}le(t){this.ue&&(this.ue.close(),this.ue=void 0,this.onclose&&this.onclose(t))}}class V{constructor(t,e,s,i,n,r){this.u=s,this.Yt=e,this.de=i,this.fe=n,this.$=t,this.onreceive=null,this.onclose=null,this.pe=r}async connect(t,s){let i;return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,B,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.Yt&&(i=await this.Yt()),new Promise(((n,r)=>{let o;t=t.replace(/^http/,"ws");const h=this.$.getCookieString(t);let c=!1;if(g.isNode||g.isReactNative){const e={},[s,n]=$();e[s]=n,i&&(e[W.Authorization]=`Bearer ${i}`),h&&(e[W.Cookie]=h),o=new this.fe(t,void 0,{headers:{...e,...this.pe}})}else i&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(i)}`);o||(o=new this.fe(t)),s===B.Binary&&(o.binaryType="arraybuffer"),o.onopen=s=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.we=o,c=!0,n()},o.onerror=t=>{let s=null;s="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${s}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${m(t.data,this.de)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.le(t)}},o.onclose=t=>{if(c)this.le(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",r(new Error(e))}}}))}send(t){return this.we&&this.we.readyState===this.fe.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${m(t,this.de)}.`),this.we.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.we&&this.le(void 0),Promise.resolve()}le(t){this.we&&(this.we.onclose=()=>{},this.we.onmessage=()=>{},this.we.onerror=()=>{},this.we.close(),this.we=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.ge(t)||!1!==t.wasClean&&1e3===t.code?t instanceof Error?this.onclose(t):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)))}ge(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class K{constructor(t,s={}){var i;if(this.me=()=>{},this.features={},this.ye=1,w.isRequired(t,"url"),this.u=void 0===(i=s.logger)?new E(e.Information):null===i?f.instance:void 0!==i.log?i:new E(i),this.baseUrl=this.be(t),(s=s||{}).logMessageContent=void 0!==s.logMessageContent&&s.logMessageContent,"boolean"!=typeof s.withCredentials&&void 0!==s.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");s.withCredentials=void 0===s.withCredentials||s.withCredentials,s.timeout=void 0===s.timeout?1e5:s.timeout;let n=null,r=null;g.isNode&&(n=function(){throw new Error("Trying to import 'ws' in the browser.")}(),r=function(){throw new Error("Trying to import 'eventsource' in the browser.")}()),g.isNode||"undefined"==typeof WebSocket||s.WebSocket?g.isNode&&!s.WebSocket&&n&&(s.WebSocket=n):s.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||s.EventSource?g.isNode&&!s.EventSource&&void 0!==r&&(s.EventSource=r):s.EventSource=EventSource,this.$=new O(s.httpClient||new H(this.u),s.accessTokenFactory),this.ut="Disconnected",this.dt=!1,this.ie=s,this.onreceive=null,this.onclose=null}async start(t){if(t=t||B.Binary,w.isIn(t,B,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${B[t]}'.`),"Disconnected"!==this.ut)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this.ut="Connecting",this.ve=this.yt(t),await this.ve,"Disconnecting"===this.ut){const t="Failed to start the HttpConnection before stop() was called.";return this.u.log(e.Error,t),await this.It,Promise.reject(new r(t))}if("Connected"!==this.ut){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this.u.log(e.Error,t),Promise.reject(new r(t))}this.dt=!0}send(t){return"Connected"!==this.ut?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.Ee||(this.Ee=new G(this.transport)),this.Ee.send(t))}async stop(t){return"Disconnected"===this.ut?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this.ut?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.It):(this.ut="Disconnecting",this.It=new Promise((t=>{this.me=t})),await this._t(t),void await this.It)}async _t(t){this.$e=t;try{await this.ve}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Ce()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async yt(t){let s=this.baseUrl;this.Yt=this.ie.accessTokenFactory,this.$.Yt=this.Yt;try{if(this.ie.skipNegotiation){if(this.ie.transport!==F.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Se(F.WebSockets),await this.ke(s,t)}else{let e=null,i=0;do{if(e=await this.Pe(s),"Disconnecting"===this.ut||"Disconnected"===this.ut)throw new r("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(s=e.url),e.accessToken){const t=e.accessToken;this.Yt=()=>t,this.$.Zt=t,this.$.Yt=void 0}i++}while(e.url&&i<100);if(100===i&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.Te(s,this.ie.transport,e,t)}this.transport instanceof J&&(this.features.inherentKeepAlive=!0),"Connecting"===this.ut&&(this.u.log(e.Debug,"The HttpConnection connected successfully."),this.ut="Connected")}catch(t){return this.u.log(e.Error,"Failed to start the connection: "+t),this.ut="Disconnected",this.transport=void 0,this.me(),Promise.reject(t)}}async Pe(t){const s={},[n,r]=$();s[n]=r;const o=this.Ie(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...s,...this.ie.headers},timeout:this.ie.timeout,withCredentials:this.ie.withCredentials});if(200!==t.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${t.statusCode}'`));const e=JSON.parse(t.content);return(!e.negotiateVersion||e.negotiateVersion<1)&&(e.connectionToken=e.connectionId),e.useStatefulReconnect&&!0!==this.ie._e?Promise.reject(new a("Client didn't negotiate Stateful Reconnect but the server did.")):e}catch(t){let s="Failed to complete negotiation with the server: "+t;return t instanceof i&&404===t.statusCode&&(s+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,s),Promise.reject(new a(s))}}He(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async Te(t,s,i,n){let o=this.He(t,i.connectionToken);if(this.De(s))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=s,await this.ke(o,n),void(this.connectionId=i.connectionId);const h=[],a=i.availableTransports||[];let u=i;for(const i of a){const a=this.Re(i,s,n,!0===(null==u?void 0:u.useStatefulReconnect));if(a instanceof Error)h.push(`${i.transport} failed:`),h.push(a);else if(this.De(a)){if(this.transport=a,!u){try{u=await this.Pe(t)}catch(t){return Promise.reject(t)}o=this.He(t,u.connectionToken)}try{return await this.ke(o,n),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${i.transport}': ${t}`),u=void 0,h.push(new c(`${i.transport} failed: ${t}`,F[i.transport])),"Connecting"!==this.ut){const t="Failed to select transport before stop() was called.";return this.u.log(e.Debug,t),Promise.reject(new r(t))}}}}return h.length>0?Promise.reject(new l(`Unable to connect to the server with any of the available transports. ${h.join(" ")}`,h)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}Se(t){switch(t){case F.WebSockets:if(!this.ie.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new V(this.$,this.Yt,this.u,this.ie.logMessageContent,this.ie.WebSocket,this.ie.headers||{});case F.ServerSentEvents:if(!this.ie.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new z(this.$,this.$.Zt,this.u,this.ie);case F.LongPolling:return new J(this.$,this.u,this.ie);default:throw new Error(`Unknown transport: ${t}.`)}}ke(t,e){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async s=>{let i=!1;if(this.features.reconnect){try{this.features.disconnected(),await this.transport.connect(t,e),await this.features.resend()}catch{i=!0}i&&this.Ce(s)}else this.Ce(s)}:this.transport.onclose=t=>this.Ce(t),this.transport.connect(t,e)}Re(t,s,i,n){const r=F[t.transport];if(null==r)return this.u.log(e.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(!function(t,e){return!t||0!=(e&t)}(s,r))return this.u.log(e.Debug,`Skipping transport '${F[r]}' because it was disabled by the client.`),new h(`'${F[r]}' is disabled by the client.`,r);if(!(t.transferFormats.map((t=>B[t])).indexOf(i)>=0))return this.u.log(e.Debug,`Skipping transport '${F[r]}' because it does not support the requested transfer format '${B[i]}'.`),new Error(`'${F[r]}' does not support ${B[i]}.`);if(r===F.WebSockets&&!this.ie.WebSocket||r===F.ServerSentEvents&&!this.ie.EventSource)return this.u.log(e.Debug,`Skipping transport '${F[r]}' because it is not supported in your environment.'`),new o(`'${F[r]}' is not supported in your environment.`,r);this.u.log(e.Debug,`Selecting transport '${F[r]}'.`);try{return this.features.reconnect=r===F.WebSockets?n:void 0,this.Se(r)}catch(t){return t}}De(t){return t&&"object"==typeof t&&"connect"in t}Ce(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.ut}.`),this.transport=void 0,t=this.$e||t,this.$e=void 0,"Disconnected"!==this.ut){if("Connecting"===this.ut)throw this.u.log(e.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this.ut&&this.me(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Ee&&(this.Ee.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Ee=void 0),this.connectionId=void 0,this.ut="Disconnected",this.dt){this.dt=!1;try{this.onclose&&this.onclose(t)}catch(s){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${s}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}be(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const s=window.document.createElement("a");return s.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${s.href}'.`),s.href}Ie(t){const e=new URL(t);e.pathname.endsWith("/")?e.pathname+="negotiate":e.pathname+="/negotiate";const s=new URLSearchParams(e.searchParams);return s.has("negotiateVersion")||s.append("negotiateVersion",this.ye.toString()),s.has("useStatefulReconnect")?"true"===s.get("useStatefulReconnect")&&(this.ie._e=!0):!0===this.ie._e&&s.append("useStatefulReconnect","true"),e.search=s.toString(),e.toString()}}class G{constructor(t){this.xe=t,this.Ae=[],this.Ue=!0,this.Le=new Q,this.Ne=new Q,this.qe=this.Me()}send(t){return this.je(t),this.Ne||(this.Ne=new Q),this.Ne.promise}stop(){return this.Ue=!1,this.Le.resolve(),this.qe}je(t){if(this.Ae.length&&typeof this.Ae[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.Ae} but was of type ${typeof t}`);this.Ae.push(t),this.Le.resolve()}async Me(){for(;;){if(await this.Le.promise,!this.Ue){this.Ne&&this.Ne.reject("Connection stopped.");break}this.Le=new Q;const t=this.Ne;this.Ne=void 0;const e="string"==typeof this.Ae[0]?this.Ae.join(""):G.We(this.Ae);this.Ae.length=0;try{await this.xe.send(e),t.resolve()}catch(e){t.reject(e)}}}static We(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),s=new Uint8Array(e);let i=0;for(const e of t)s.set(new Uint8Array(e),i),i+=e.byteLength;return s.buffer}}class Q{constructor(){this.promise=new Promise(((t,e)=>[this.j,this.Oe]=[t,e]))}resolve(){this.j()}reject(t){this.Oe(t)}}class Y{constructor(){this.name="json",this.version=2,this.transferFormat=B.Text}parseMessages(t,s){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===s&&(s=f.instance);const i=D.parse(t),n=[];for(const t of i){const i=JSON.parse(t);if("number"!=typeof i.type)throw new Error("Invalid payload.");switch(i.type){case x.Invocation:this.U(i);break;case x.StreamItem:this.Fe(i);break;case x.Completion:this.Be(i);break;case x.Ping:case x.Close:break;case x.Ack:this.Xe(i);break;case x.Sequence:this.Je(i);break;default:s.log(e.Information,"Unknown message type '"+i.type+"' ignored.");continue}n.push(i)}return n}writeMessage(t){return D.write(JSON.stringify(t))}U(t){this.ze(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.ze(t.invocationId,"Invalid payload for Invocation message.")}Fe(t){if(this.ze(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}Be(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.ze(t.error,"Invalid payload for Completion message."),this.ze(t.invocationId,"Invalid payload for Completion message.")}Xe(t){if("number"!=typeof t.sequenceId)throw new Error("Invalid SequenceId for Ack message.")}Je(t){if("number"!=typeof t.sequenceId)throw new Error("Invalid SequenceId for Sequence message.")}ze(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const Z={trace:e.Trace,debug:e.Debug,info:e.Information,information:e.Information,warn:e.Warning,warning:e.Warning,error:e.Error,critical:e.Critical,none:e.None};class tt{configureLogging(t){if(w.isRequired(t,"logging"),void 0!==t.log)this.logger=t;else if("string"==typeof t){const e=function(t){const e=Z[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new E(e)}else this.logger=new E(t);return this}withUrl(t,e){return w.isRequired(t,"url"),w.isNotEmpty(t,"url"),this.url=t,this.httpConnectionOptions="object"==typeof e?{...this.httpConnectionOptions,...e}:{...this.httpConnectionOptions,transport:e},this}withHubProtocol(t){return w.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new j(t):this.reconnectPolicy=t:this.reconnectPolicy=new j,this}withServerTimeout(t){return w.isRequired(t,"milliseconds"),this.Ve=t,this}withKeepAliveInterval(t){return w.isRequired(t,"milliseconds"),this.Ke=t,this}withStatefulReconnect(t){return void 0===this.httpConnectionOptions&&(this.httpConnectionOptions={}),this.httpConnectionOptions._e=!0,this.Y=null==t?void 0:t.bufferSize,this}build(){const t=this.httpConnectionOptions||{};if(void 0===t.logger&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const e=new K(this.url,t);return q.create(e,this.logger||f.instance,this.protocol||new Y,this.reconnectPolicy,this.Ve,this.Ke,this.Y)}}return Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0}),Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(t,e){return new Uint8Array(Array.prototype.slice.call(this,t,e))},writable:!0}),Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,writable:!0}),s})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.signalR=e():t.signalR=e(); +//# sourceMappingURL=signalr.min.js.map \ No newline at end of file From 36754e20f819d7c24158973f2a281583774a983f Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sat, 24 Jan 2026 16:11:38 -0700 Subject: [PATCH 05/13] chore: adding tools file (Not sure if I need this) --- src/SpyderTallyControllerWebApp/dotnet-tools.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/SpyderTallyControllerWebApp/dotnet-tools.json diff --git a/src/SpyderTallyControllerWebApp/dotnet-tools.json b/src/SpyderTallyControllerWebApp/dotnet-tools.json new file mode 100644 index 0000000..a74bf0b --- /dev/null +++ b/src/SpyderTallyControllerWebApp/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "10.0.2", + "commands": [ + "dotnet-ef" + ], + "rollForward": false + } + } +} \ No newline at end of file From be5bc48d47460b3234864aa22be7ab34c9aba1ea Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sun, 25 Jan 2026 11:39:21 -0700 Subject: [PATCH 06/13] chore: switching to lighter-weight Spyder library classes Before this change this project was using the centralized SpyderClientManager class to get events and servers on the network, which works fine but has extra overhead like making QFT connections and pulling config files from Spyder servers before returning data, which we don't need. This change uses the base UDP listener and SpyderUdpClient classes to collect data, which has way less overhead with better overall performance. --- .../Models/ISpyderRepository.cs | 7 +- .../Models/SpyderRepository.cs | 80 ++++++++++++++----- .../Models/SystemHealthRepository.cs | 27 +++++-- src/SpyderTallyControllerWebApp/Program.cs | 11 +-- .../SpyderTallyControllerWebApp.csproj | 5 +- .../SpyderTallyEngine.cs | 11 ++- 6 files changed, 95 insertions(+), 46 deletions(-) diff --git a/src/SpyderTallyControllerWebApp/Models/ISpyderRepository.cs b/src/SpyderTallyControllerWebApp/Models/ISpyderRepository.cs index 294e32c..b7fe768 100644 --- a/src/SpyderTallyControllerWebApp/Models/ISpyderRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/ISpyderRepository.cs @@ -1,7 +1,12 @@ -namespace SpyderTallyControllerWebApp.Models +using Spyder.Client.Net.DrawingData.Deserializers; +using Spyder.Client.Net.Notifications; + +namespace SpyderTallyControllerWebApp.Models { public interface ISpyderRepository { + event DrawingDataReceivedHandler DrawingDataReceived; + Task> GetServersAsync(); Task> GetSourcesAsync(string serverIP); diff --git a/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs b/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs index aac23ba..2664179 100644 --- a/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs @@ -1,39 +1,81 @@ using Spyder.Client; +using Spyder.Client.Common; +using Spyder.Client.Net; +using Spyder.Client.Net.DrawingData.Deserializers; +using Spyder.Client.Net.Notifications; using System.Linq; namespace SpyderTallyControllerWebApp.Models { public class SpyderRepository : ISpyderRepository { - private readonly SpyderClientManager spyderManager; + private readonly SpyderServerEventListener serverEventListener; + private readonly List servers = new List(); + private readonly ReaderWriterLockSlim serversLock = new ReaderWriterLockSlim(); - public SpyderRepository(SpyderClientManager spyderManager, IConfigurationRepository configurationRepository) + public event DrawingDataReceivedHandler DrawingDataReceived; + + public SpyderRepository(SpyderServerEventListener serverEventListener) { - this.spyderManager = spyderManager; + this.serverEventListener = serverEventListener; + this.serverEventListener.DrawingDataThrottleInterval = TimeSpan.FromMilliseconds(100); + this.serverEventListener.ServerAnnounceMessageReceived += ServerEventListener_ServerAnnounceMessageReceived; + this.serverEventListener.DrawingDataReceived += ServerEventListener_DrawingDataReceived; } - public async Task> GetServersAsync() + private void ServerEventListener_DrawingDataReceived(object sender, DrawingDataReceivedEventArgs e) + { + DrawingDataReceived?.Invoke(this, e); + } + + private void ServerEventListener_ServerAnnounceMessageReceived(object sender, SpyderServerAnnounceInformation serverInfo) { - var servers = await spyderManager.GetServers(); - if (servers == null) - return new List(); + //See if we already have this server + serversLock.EnterReadLock(); + bool exists = servers.Contains(serverInfo.Address); + serversLock.ExitReadLock(); - return servers - .Select(s => s.ServerIP) - .ToList(); + //Do we need to add this? + if(exists) + { + serversLock.EnterWriteLock(); + servers.Add(serverInfo.Address); + serversLock.ExitWriteLock(); + } + } + + public async Task> GetServersAsync() + { + try + { + serversLock.EnterReadLock(); + return [.. servers]; + } + finally + { + serversLock.ExitReadLock(); + } } public async Task> GetSourcesAsync(string serverIP) { - var server = await spyderManager.GetServerAsync(serverIP); - var sources = await server?.GetSources(); - if (sources == null) - return new List(); - - return sources - .Where(s => !string.IsNullOrWhiteSpace(s?.Name)) - .Select(s => s.Name) - .ToList(); + //Connect to server (note we don't actually care about the hardware type for this simple call) + var client = new SpyderUdpClient(HardwareType.Spyder300, serverIP); + try + { + if (await client.StartupAsync()) + { + var sources = await client.GetSources(); + if(sources != null) + return sources?.Select(s => s.Name).ToList(); + } + } + finally + { + await client?.ShutdownAsync(); + } + + return []; } } } diff --git a/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs b/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs index 23d9698..9688954 100644 --- a/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs @@ -95,15 +95,26 @@ private string SplitAndGetValue(string fullText, string prefix, string delimiter private async Task RunProcessAndGetLine(string processName, string args = null) { - Process process = Process.Start(processName, args); - process.StartInfo.UseShellExecute = false; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.CreateNoWindow = true; - process.Start(); + //Sanity check on process + if (!OperatingSystem.IsLinux()) + return "OS Not Supported"; - string response = await process.StandardOutput.ReadToEndAsync(); - process.WaitForExit(); - return response; + try + { + Process process = Process.Start(processName, args); + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.CreateNoWindow = true; + process.Start(); + + string response = await process.StandardOutput.ReadToEndAsync(); + process.WaitForExit(); + return response; + } + catch(Exception ex) + { + return $"Error: {ex.Message}"; + } } } } diff --git a/src/SpyderTallyControllerWebApp/Program.cs b/src/SpyderTallyControllerWebApp/Program.cs index e37d176..8518489 100644 --- a/src/SpyderTallyControllerWebApp/Program.cs +++ b/src/SpyderTallyControllerWebApp/Program.cs @@ -1,22 +1,17 @@ +using Spyder.Client.Net.Notifications; using SpyderTallyControllerWebApp; using SpyderTallyControllerWebApp.Hubs; using SpyderTallyControllerWebApp.Models; using SpyderTallyControllerWebApp.Services; -var spyderManager = new Spyder.Client.SpyderClientManager(); -spyderManager.ServerListChanged += async (s, e) => -{ - foreach (var server in (await spyderManager.GetServers())) - server.DrawingDataThrottleInterval = TimeSpan.FromMilliseconds(100); -}; -await spyderManager.StartupAsync(); +var serverEventListener = await SpyderServerEventListener.GetInstanceAsync(); var builder = WebApplication.CreateBuilder(args); //Allow access on outside adapters builder.WebHost.UseUrls("http://*:5000"); -builder.Services.AddSingleton(spyderManager); +builder.Services.AddSingleton(serverEventListener); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj index 5e87d47..1c6bdc8 100644 --- a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj +++ b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj @@ -14,6 +14,7 @@ + @@ -21,8 +22,4 @@ - - - - diff --git a/src/SpyderTallyControllerWebApp/SpyderTallyEngine.cs b/src/SpyderTallyControllerWebApp/SpyderTallyEngine.cs index 6387141..3448e43 100644 --- a/src/SpyderTallyControllerWebApp/SpyderTallyEngine.cs +++ b/src/SpyderTallyControllerWebApp/SpyderTallyEngine.cs @@ -9,7 +9,7 @@ namespace SpyderTallyControllerWebApp public class SpyderTallyEngine { private readonly IConfigurationRepository configurationRepository; - private readonly SpyderClientManager spyderManager; + private readonly ISpyderRepository spyderRepository; private readonly IRelayRepository relayRepository; private readonly TallyDeviceConfiguration deviceConfig; @@ -17,7 +17,7 @@ public class SpyderTallyEngine public SpyderTallyEngine(IConfigurationRepository configurationRepository, IRelayRepository relayRepository, - SpyderClientManager spyderManager) + ISpyderRepository spyderRepository) { this.configurationRepository = configurationRepository; this.appConfig = configurationRepository.GetTallyAppConfiguration(); @@ -26,9 +26,8 @@ public SpyderTallyEngine(IConfigurationRepository configurationRepository, this.relayRepository = relayRepository; - this.spyderManager = spyderManager; - spyderManager.RaiseDrawingDataChanged = true; - spyderManager.DrawingDataReceived += SpyderManager_DrawingDataReceived; + this.spyderRepository = spyderRepository; + spyderRepository.DrawingDataReceived += SpyderRepository_DrawingDataReceived; } private void ConfigurationRepository_TallyAppConfigurationChanged(object sender, TallyAppConfiguration e) @@ -38,7 +37,7 @@ private void ConfigurationRepository_TallyAppConfigurationChanged(object sender, UpdateTallies(null, null); } - private void SpyderManager_DrawingDataReceived(object sender, DrawingDataReceivedEventArgs e) + private void SpyderRepository_DrawingDataReceived(object sender, DrawingDataReceivedEventArgs e) { UpdateTallies(e.ServerIP, e.DrawingData); } From 4379faeb2bd0d28eac073416940a1e2d990ac5a9 Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sun, 25 Jan 2026 18:03:10 -0700 Subject: [PATCH 07/13] chore: clean up on locking logic in SpyderRepository --- .../Models/SpyderRepository.cs | 168 +++++++++--------- 1 file changed, 88 insertions(+), 80 deletions(-) diff --git a/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs b/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs index 2664179..c09a653 100644 --- a/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/SpyderRepository.cs @@ -1,81 +1,89 @@ -using Spyder.Client; -using Spyder.Client.Common; -using Spyder.Client.Net; -using Spyder.Client.Net.DrawingData.Deserializers; -using Spyder.Client.Net.Notifications; -using System.Linq; - -namespace SpyderTallyControllerWebApp.Models -{ - public class SpyderRepository : ISpyderRepository - { - private readonly SpyderServerEventListener serverEventListener; - private readonly List servers = new List(); - private readonly ReaderWriterLockSlim serversLock = new ReaderWriterLockSlim(); - - public event DrawingDataReceivedHandler DrawingDataReceived; - - public SpyderRepository(SpyderServerEventListener serverEventListener) - { - this.serverEventListener = serverEventListener; - this.serverEventListener.DrawingDataThrottleInterval = TimeSpan.FromMilliseconds(100); - this.serverEventListener.ServerAnnounceMessageReceived += ServerEventListener_ServerAnnounceMessageReceived; - this.serverEventListener.DrawingDataReceived += ServerEventListener_DrawingDataReceived; - } - - private void ServerEventListener_DrawingDataReceived(object sender, DrawingDataReceivedEventArgs e) - { - DrawingDataReceived?.Invoke(this, e); - } - - private void ServerEventListener_ServerAnnounceMessageReceived(object sender, SpyderServerAnnounceInformation serverInfo) - { - //See if we already have this server - serversLock.EnterReadLock(); - bool exists = servers.Contains(serverInfo.Address); - serversLock.ExitReadLock(); - - //Do we need to add this? - if(exists) - { - serversLock.EnterWriteLock(); - servers.Add(serverInfo.Address); - serversLock.ExitWriteLock(); - } - } - - public async Task> GetServersAsync() - { - try - { - serversLock.EnterReadLock(); - return [.. servers]; - } - finally - { - serversLock.ExitReadLock(); - } - } - - public async Task> GetSourcesAsync(string serverIP) - { - //Connect to server (note we don't actually care about the hardware type for this simple call) - var client = new SpyderUdpClient(HardwareType.Spyder300, serverIP); - try - { - if (await client.StartupAsync()) - { - var sources = await client.GetSources(); - if(sources != null) - return sources?.Select(s => s.Name).ToList(); - } - } - finally - { - await client?.ShutdownAsync(); - } - - return []; - } - } +using Spyder.Client; +using Spyder.Client.Common; +using Spyder.Client.Net; +using Spyder.Client.Net.DrawingData.Deserializers; +using Spyder.Client.Net.Notifications; +using System.Linq; + +namespace SpyderTallyControllerWebApp.Models +{ + public class SpyderRepository : ISpyderRepository + { + private readonly SpyderServerEventListener serverEventListener; + private readonly HashSet servers = new HashSet(); + private readonly object serversLock = new object(); + + public event DrawingDataReceivedHandler DrawingDataReceived; + + public SpyderRepository(SpyderServerEventListener serverEventListener) + { + this.serverEventListener = serverEventListener; + this.serverEventListener.DrawingDataThrottleInterval = TimeSpan.FromMilliseconds(100); + this.serverEventListener.ServerAnnounceMessageReceived += ServerEventListener_ServerAnnounceMessageReceived; + this.serverEventListener.DrawingDataReceived += ServerEventListener_DrawingDataReceived; + } + + private void ServerEventListener_DrawingDataReceived(object sender, DrawingDataReceivedEventArgs e) + { + DrawingDataReceived?.Invoke(this, e); + } + + private void ServerEventListener_ServerAnnounceMessageReceived(object sender, SpyderServerAnnounceInformation serverInfo) + { + lock (serversLock) + { + servers.Add(serverInfo.Address); // HashSet.Add handles duplicates automatically + } + } + + public Task> GetServersAsync() + { + lock (serversLock) + { + return Task.FromResult(servers.ToList()); + } + } + + public async Task> GetSourcesAsync(string serverIP) + { + var timeout = TimeSpan.FromSeconds(2); + + try + { + var task = GetSourcesInternalAsync(serverIP); + return await task.WaitAsync(timeout); + } + catch (TimeoutException) + { + return []; + } + catch (Exception) + { + return []; + } + } + + private async Task> GetSourcesInternalAsync(string serverIP) + { + var client = new SpyderUdpClient(HardwareType.Spyder300, serverIP); + try + { + if (await client.StartupAsync()) + { + var sources = await client.GetSources(); + return sources?.Select(s => s.Name).ToList() ?? []; + } + return []; + } + finally + { + // Fire and forget shutdown to avoid blocking on cleanup + _ = Task.Run(async () => + { + try { await client.ShutdownAsync(); } + catch { /* ignore cleanup errors */ } + }); + } + } + } } From eb42809437e517d048c3e426b0b9e8b45f26a42d Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sun, 25 Jan 2026 18:03:34 -0700 Subject: [PATCH 08/13] feat: added drop-down implementation for selecting server and sources in config page --- .../Controllers/ConfigurationController.cs | 19 + .../Views/Configuration/Index.cshtml | 408 ++++++++++++++---- 2 files changed, 346 insertions(+), 81 deletions(-) diff --git a/src/SpyderTallyControllerWebApp/Controllers/ConfigurationController.cs b/src/SpyderTallyControllerWebApp/Controllers/ConfigurationController.cs index b95a09f..49af99d 100644 --- a/src/SpyderTallyControllerWebApp/Controllers/ConfigurationController.cs +++ b/src/SpyderTallyControllerWebApp/Controllers/ConfigurationController.cs @@ -99,5 +99,24 @@ private void ValidateModel(ConfigurationViewModel vm) (TallyMode.ForceOff, "Force Off") }; } + + [HttpGet] + public async Task GetServers() + { + var servers = await spyderRepository.GetServersAsync(); + return Json(servers); + } + + [HttpGet] + public async Task GetSources(string serverIP) + { + if (string.IsNullOrWhiteSpace(serverIP)) + { + return Json(new List()); + } + + var sources = await spyderRepository.GetSourcesAsync(serverIP); + return Json(sources); + } } } diff --git a/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml b/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml index df0d3cf..3b9c2c8 100644 --- a/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Configuration/Index.cshtml @@ -1,64 +1,178 @@ -@model ConfigurationViewModel -@{ - ViewData["Title"] = "Configuration"; -} - -
- -
- -
-

Tally Configuration

- - - - - - - - - - - @foreach (var tally in Model.TallyConfigurations) - { - - - - - - - - - - } - - -
Relay IndexSpyder ServerSpyder SourceMode
- - @tally.TallyIndex - -
- - -
-
-
- - -
-
-
- - -
-
-
- -
-
- -
-
+@model ConfigurationViewModel +@{ + ViewData["Title"] = "Configuration"; +} + + + + + +
+ +
+

Tally Configuration

+ + + + + + + + + + + @foreach (var tally in Model.TallyConfigurations) + { + + + + + + + + + + } + + +
Relay IndexSpyder ServerSpyder SourceMode
+ + @tally.TallyIndex + +
+
+ + +
+ +
+
+
+
+ + +
+ + @if (!string.IsNullOrEmpty(tally.SpyderServerIP) && Model.SourcesByServer.TryGetValue(tally.SpyderServerIP, out var sources)) + { + @foreach (var source in sources) + { + + } + } + + +
+
+
+ + +
+
+
+ + + @foreach (var server in Model.AvailableServers) + { + + } + + +
+
+ +
+
@@ -69,24 +183,156 @@
-@section Scripts { - +@section Scripts { + } From 2286f448091255758785bf4ca73ccb4225f7bdfe Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sun, 25 Jan 2026 21:35:41 -0700 Subject: [PATCH 09/13] chore: cleanup of response when non-Linux OS in health repository --- .../Models/SystemHealthRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs b/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs index 9688954..e671ff4 100644 --- a/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs +++ b/src/SpyderTallyControllerWebApp/Models/SystemHealthRepository.cs @@ -97,7 +97,7 @@ private async Task RunProcessAndGetLine(string processName, string args { //Sanity check on process if (!OperatingSystem.IsLinux()) - return "OS Not Supported"; + return null; try { From d1b06b6d8117fcf8f751d2d27f19cb1256730c7d Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sat, 14 Feb 2026 15:30:02 -0700 Subject: [PATCH 10/13] fix: updating nginx.conf to allow websocket pass-thru support --- docs/sd_card/nginx.conf | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/docs/sd_card/nginx.conf b/docs/sd_card/nginx.conf index 55e0b3d..4f8839e 100644 --- a/docs/sd_card/nginx.conf +++ b/docs/sd_card/nginx.conf @@ -20,28 +20,25 @@ http { ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; - # Logging Settings - # access_log /var/log/nginx/access.log; - # error_log /var/log/nginx/error.log; - # Gzip Settings gzip on; - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; - - server { - listen 80 default_server; - location / { - proxy_pass http://127.0.0.1:5000; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Host $host; - } - } + # WebSocket support (required for SignalR) + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + server { + listen 80 default_server; + location / { + proxy_pass http://127.0.0.1:5000; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } + } } - From 386831575d513fc04f4ac9ef99eb33f595ce7dcb Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sat, 14 Feb 2026 15:30:49 -0700 Subject: [PATCH 11/13] chore: updating SpyderClientLibrary nuget package version Updating to SpyderClientLibrary 5.0.0 to add support for Spyder-S and fix an issue with Spyder X80 DrawingData deserialization --- .gitignore | 1 + src/SpyderTallyControllerLinux.sln | 4 ++-- .../SpyderTallyControllerWebApp.csproj | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0d55e56..3a132b9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.userprefs .vscode/ +.claude/ # Build results [Dd]ebug/ diff --git a/src/SpyderTallyControllerLinux.sln b/src/SpyderTallyControllerLinux.sln index 6388671..59d1307 100644 --- a/src/SpyderTallyControllerLinux.sln +++ b/src/SpyderTallyControllerLinux.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32014.148 +# Visual Studio Version 18 +VisualStudioVersion = 18.2.11408.102 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpyderTallyControllerWebApp", "SpyderTallyControllerWebApp\SpyderTallyControllerWebApp.csproj", "{1E5F6F1B-9473-4A89-A69D-5014519E8002}" EndProject diff --git a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj index 1c6bdc8..7763230 100644 --- a/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj +++ b/src/SpyderTallyControllerWebApp/SpyderTallyControllerWebApp.csproj @@ -1,4 +1,4 @@ - + net10.0 @@ -14,7 +14,7 @@ - + From 4c9f86da8143cca07009f202eeabacf82440478d Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sat, 14 Feb 2026 15:40:46 -0700 Subject: [PATCH 12/13] feat: adding a default red tally icon for the favicon and page header --- .../Views/Shared/_Layout.cshtml | 6 +++++- .../wwwroot/img/tally-icon.svg | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/SpyderTallyControllerWebApp/wwwroot/img/tally-icon.svg diff --git a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml index a9d761e..5419cd4 100644 --- a/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml +++ b/src/SpyderTallyControllerWebApp/Views/Shared/_Layout.cshtml @@ -10,6 +10,7 @@ document.documentElement.setAttribute('data-theme', 'dark'); } + @@ -18,7 +19,10 @@