Skip to content

Commit

Permalink
refactor: fix for null connection
Browse files Browse the repository at this point in the history
  • Loading branch information
aguacongas committed Oct 8, 2020
1 parent f263bdb commit 5ec7f66
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ProviderClient(HubConnectionFactory hubConnectionFactory)
/// <returns></returns>
public Task KeyRevokedAsync(string kind, Guid id, CancellationToken cancellationToken = default)
{
return GetConnection(cancellationToken).SendAsync(nameof(IProviderHub.KeyRevoked), kind, id, cancellationToken);
return GetConnection(cancellationToken)?.SendAsync(nameof(IProviderHub.KeyRevoked), kind, id, cancellationToken) ?? Task.CompletedTask;
}

/// <summary>
Expand All @@ -50,7 +50,7 @@ public Task KeyRevokedAsync(string kind, Guid id, CancellationToken cancellation
/// <returns></returns>
public Task ProviderAddedAsync(string scheme, CancellationToken cancellationToken = default)
{
return GetConnection(cancellationToken).SendAsync(nameof(IProviderHub.ProviderAdded), scheme, cancellationToken);
return GetConnection(cancellationToken)?.SendAsync(nameof(IProviderHub.ProviderAdded), scheme, cancellationToken) ?? Task.CompletedTask;
}

/// <summary>
Expand All @@ -61,7 +61,7 @@ public Task ProviderAddedAsync(string scheme, CancellationToken cancellationToke
/// <returns></returns>
public Task ProviderRemovedAsync(string scheme, CancellationToken cancellationToken = default)
{
return GetConnection(cancellationToken).SendAsync(nameof(IProviderHub.ProviderRemoved), scheme, cancellationToken);
return GetConnection(cancellationToken)?.SendAsync(nameof(IProviderHub.ProviderRemoved), scheme, cancellationToken) ?? Task.CompletedTask;
}

/// <summary>
Expand All @@ -72,7 +72,7 @@ public Task ProviderRemovedAsync(string scheme, CancellationToken cancellationTo
/// <returns></returns>
public Task ProviderUpdatedAsync(string scheme, CancellationToken cancellationToken = default)
{
return GetConnection(cancellationToken).SendAsync(nameof(IProviderHub.ProviderUpdated), scheme, cancellationToken);
return GetConnection(cancellationToken)?.SendAsync(nameof(IProviderHub.ProviderUpdated), scheme, cancellationToken) ?? Task.CompletedTask;
}

private HubConnection GetConnection(CancellationToken cancellationToken)
Expand Down

0 comments on commit 5ec7f66

Please sign in to comment.