mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-04-07 10:11:10 +00:00
Updated API credential logic, exchange implementation are expected to provide their own credentials implementation with ApiCredentials as base class Removed ApiCredentials implementation used by most exchanges Removed ApiCredentialsType Enum Added CredentialSet base class and implementations for defining different API credentials Added optional type param to AuthenticationProvider for the specific API credential type to improve type safety Moved AuthenticationProvider/ApiCredentials from BaseApiClient to RestApiClient/SocketApiClient base classes Added optional type params to RestApiClient/SocketApiClient base class to specify the AuthenticationProvider type and credentials type to improve type safety Moved SetOptions/SetApiCredentials from BaseApiClient to RestApiClient/SocketApiClient Extracted LibraryOptions<TRestOptions, TSocketOptions, TEnvironment> without TApiCredentials for libraries without API credentials Removed ApiCredentials from ApiOptions, credentials can only be configured at library, rest or socket level Added EnvironmentName to RestApiClient/SocketApiClient property Added Unknown enum value to Shared interfaces SharedOrderStatus, SharedTransferStatus and SharedTriggerOrderStatus enums Updated Enum converter to map value to an undefined Enum value instead of the first Enum value Added support for checking for missing fields on RestIntegrationTest Added BytesToHexString and HexToBytesString to ExchangeHelpers static class Fixed bug where WebSocket connections are not reconnected when configuring Proxy with SetUpdates Removed legacy CryptoBaseClient, CryptoRestClient and CryptoSocketClient
81 lines
2.7 KiB
C#
81 lines
2.7 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using CryptoExchange.Net.Authentication;
|
|
using CryptoExchange.Net.Objects.Options;
|
|
using CryptoExchange.Net.Objects.Sockets;
|
|
|
|
namespace CryptoExchange.Net.Interfaces.Clients
|
|
{
|
|
/// <summary>
|
|
/// Base class for socket API implementations
|
|
/// </summary>
|
|
public interface ISocketClient : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// The exchange name
|
|
/// </summary>
|
|
string Exchange { get; }
|
|
|
|
/// <summary>
|
|
/// The options provided for this client
|
|
/// </summary>
|
|
ExchangeOptions ClientOptions { get; }
|
|
|
|
/// <summary>
|
|
/// Incoming kilobytes per second of data
|
|
/// </summary>
|
|
public double IncomingKbps { get; }
|
|
|
|
/// <summary>
|
|
/// The current amount of connections to the API from this client. A connection can have multiple subscriptions.
|
|
/// </summary>
|
|
public int CurrentConnections { get; }
|
|
|
|
/// <summary>
|
|
/// The current amount of subscriptions running from the client
|
|
/// </summary>
|
|
public int CurrentSubscriptions { get; }
|
|
|
|
/// <summary>
|
|
/// Whether client is disposed
|
|
/// </summary>
|
|
bool Disposed { get; }
|
|
|
|
/// <summary>
|
|
/// Unsubscribe from a stream using the subscription id received when starting the subscription
|
|
/// </summary>
|
|
/// <param name="subscriptionId">The id of the subscription to unsubscribe</param>
|
|
/// <returns></returns>
|
|
Task UnsubscribeAsync(int subscriptionId);
|
|
|
|
/// <summary>
|
|
/// Unsubscribe from a stream
|
|
/// </summary>
|
|
/// <param name="subscription">The subscription to unsubscribe</param>
|
|
/// <returns></returns>
|
|
Task UnsubscribeAsync(UpdateSubscription subscription);
|
|
|
|
/// <summary>
|
|
/// Unsubscribe all subscriptions
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
Task UnsubscribeAllAsync();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public interface ISocketClient<TApiCredentials> : ISocketClient where TApiCredentials : ApiCredentials
|
|
{
|
|
|
|
/// <summary>
|
|
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
|
|
/// </summary>
|
|
/// <param name="credentials">The credentials to set</param>
|
|
void SetApiCredentials(TApiCredentials credentials);
|
|
|
|
/// <summary>
|
|
/// Update specific options
|
|
/// </summary>
|
|
/// <param name="options">Options to update. Only specific options are changeable after the client has been created</param>
|
|
void SetOptions(UpdateOptions<TApiCredentials> options);
|
|
}
|
|
} |