Skip to content

Commit

Permalink
fix: relayer reconnects on disposal
Browse files Browse the repository at this point in the history
  • Loading branch information
skibitsky committed Nov 9, 2023
1 parent 55415cc commit 6f203ab
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions WalletConnectSharp.Core/Controllers/Relayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ protected virtual void RegisterProviderEventListeners()

protected virtual void RegisterEventListeners()
{
this.OnConnectionStalled += async (sender, args) =>
{
if (this.Provider.Connection.IsPaused)
return;
this.OnConnectionStalled += OnConnectionStalledHandler;
}

await this.RestartTransport();
};
private async void OnConnectionStalledHandler(object sender, EventArgs e)
{
if (this.Provider.Connection.IsPaused)
return;

await this.RestartTransport();
}

protected virtual async void OnProviderPayload(string payloadJson)
Expand Down Expand Up @@ -499,6 +501,9 @@ protected virtual void Dispose(bool disposing)

if (disposing)
{
_transportExplicitlyClosed = true;
this.OnConnectionStalled -= OnConnectionStalledHandler;

Subscriber?.Dispose();
Publisher?.Dispose();
Messages?.Dispose();
Expand Down

0 comments on commit 6f203ab

Please sign in to comment.