Skip to content

Commit b1e5d86

Browse files
committed
Added ClearUserClients method to user client provider
1 parent e51c5bd commit b1e5d86

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

HTX.Net/Clients/HTXUserClientProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ public void InitializeUserClient(string userIdentifier, ApiCredentials credentia
5353
CreateSocketClient(userIdentifier, credentials, environment);
5454
}
5555

56+
/// <inheritdoc />
57+
public void ClearUserClients(string userIdentifier)
58+
{
59+
_restClients.TryRemove(userIdentifier, out _);
60+
_socketClients.TryRemove(userIdentifier, out _);
61+
}
62+
5663
/// <inheritdoc />
5764
public IHTXRestClient GetRestClient(string userIdentifier, ApiCredentials? credentials = null, HTXEnvironment? environment = null)
5865
{

HTX.Net/Interfaces/Clients/IHTXUserClientProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public interface IHTXUserClientProvider
1515
/// <param name="environment">The environment to use</param>
1616
void InitializeUserClient(string userIdentifier, ApiCredentials credentials, HTXEnvironment? environment = null);
1717

18+
/// <summary>
19+
/// Reset the cached clients for a user. This can be useful when a user changes API credentials.
20+
/// </summary>
21+
public void ClearUserClients(string userIdentifier);
22+
1823
/// <summary>
1924
/// Get the Rest client for a specific user. In case the client does not exist yet it will be created and the <paramref name="credentials"/> should be provided, unless <see cref="InitializeUserClient" /> has been called prior for this user.
2025
/// </summary>

0 commit comments

Comments
 (0)