Skip to content

Commit

Permalink
Check for adding existing connections
Browse files Browse the repository at this point in the history
• Added a check for existing Websocket connections, related to the issue #112
  • Loading branch information
androidseb25 committed Dec 25, 2024
1 parent e2b2e81 commit 2170e2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Services/GotifySocketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ private static void StartWsConn(string gotifyServerUrl, string clientToken)
if (_websocketThreads == null)
_websocketThreads = new Dictionary<string, WebSockClient>();

_websocketThreads.Add(clientToken, wsc);
_websocketThreads.TryGetValue(clientToken, out var storedWebSockClient);
if (storedWebSockClient == null)
_websocketThreads.Add(clientToken, wsc);
else
Console.WriteLine($"Client: {clientToken} already connected! Skipping...");

Thread.Sleep(Timeout.Infinite);
}
Expand Down
2 changes: 1 addition & 1 deletion iGotify Notification Assist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.71" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.72" />
<PackageReference Include="secntfy.nuget" Version="1.0.5" />
<PackageReference Include="Websocket.Client" Version="5.1.2" />
</ItemGroup>
Expand Down

0 comments on commit 2170e2d

Please sign in to comment.