Skip to content

Commit

Permalink
Merge pull request #154 from WalletConnect/fix/relayer-reconnects-on-…
Browse files Browse the repository at this point in the history
…disposal

fix: relayer reconnects on disposal
  • Loading branch information
skibitsky authored Nov 9, 2023
2 parents bf7afdc + 6f203ab commit 5a5f25e
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 5a5f25e

Please sign in to comment.