Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix reconnect issue #37 #38

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion TwitchLib.EventSub.Websockets/Client/WebsocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class WebsocketClient : IDisposable
internal event AsyncEventHandler<DataReceivedArgs> OnDataReceived;
internal event AsyncEventHandler<ErrorOccuredArgs> OnErrorOccurred;

private readonly ClientWebSocket _webSocket;
private ClientWebSocket _webSocket;
private readonly ILogger<WebsocketClient> _logger;

/// <summary>
Expand All @@ -56,6 +56,8 @@ public async Task<bool> ConnectAsync(Uri url)
{
if (_webSocket.State is WebSocketState.Open or WebSocketState.Connecting)
return true;
if (_webSocket.State is WebSocketState.Closed) //after a socken is closed it cannot be reopened
_webSocket = new();

await _webSocket.ConnectAsync(url, CancellationToken.None);

Expand Down
Loading