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

ConnectClientAsync - Fix "Cannot access a disposed object." #32

Merged
merged 1 commit into from
Jan 3, 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
7 changes: 4 additions & 3 deletions src/TwitchLib.Communication/Clients/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
private CancellationTokenSource _cancellationTokenSource;

/// <summary>
/// This <see cref="_cancellationTokenSource"/> is used for <see cref="_networkServices.ListenTask"/>

Check warning on line 30 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

XML comment has cref attribute 'ListenTask' that could not be resolved

Check warning on line 30 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

XML comment has cref attribute 'ListenTask' that could not be resolved
/// whenever a call to <see cref="CancellationTokenSource.Cancel()"/> is made
/// </summary>
internal CancellationToken Token => _cancellationTokenSource.Token;

internal static TimeSpan TimeOutEstablishConnection => TimeSpan.FromSeconds(15);

protected readonly ILogger<ClientBase<T>>? Logger;

Check warning on line 37 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

Missing XML comment for publicly visible type or member 'ClientBase<T>.Logger'

Check warning on line 37 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

Missing XML comment for publicly visible type or member 'ClientBase<T>.Logger'

protected abstract string Url { get; }

Check warning on line 39 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

Missing XML comment for publicly visible type or member 'ClientBase<T>.Url'

Check warning on line 39 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

Missing XML comment for publicly visible type or member 'ClientBase<T>.Url'

/// <summary>
/// The underlying <typeparamref name="T"/> client.
Expand Down Expand Up @@ -237,16 +237,17 @@
return true;
}

// Always create new client when opening new connection
Client = CreateClient();

var first = true;
Options.ReconnectionPolicy.Reset(isReconnect);

while (!IsConnected &&
!Options.ReconnectionPolicy.AreAttemptsComplete())
{
Logger?.TraceAction(GetType(), "try to connect");

// Always create new client when opening new connection
Client = CreateClient();

if (!first)
{
await Task.Delay(Options.ReconnectionPolicy.GetReconnectInterval(), CancellationToken.None);
Expand Down Expand Up @@ -284,7 +285,7 @@
}

/// <summary>
/// Stops <see cref="_networkServices.ListenTaskAsync"/>

Check warning on line 288 in src/TwitchLib.Communication/Clients/ClientBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus (7.0.x)

XML comment has cref attribute 'ListenTaskAsync' that could not be resolved
/// by calling <see cref="CancellationTokenSource.Cancel()"/>
/// <br></br>
/// and enforces the <see cref="CloseClient"/>
Expand Down
Loading