mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-10 17:36:19 +00:00
Added interfaces to base class so they implement IDisposable
This commit is contained in:
parent
96d553d093
commit
53254e8d0f
@ -7,7 +7,7 @@
|
||||
<PropertyGroup>
|
||||
<PackageId>CryptoExchange.Net</PackageId>
|
||||
<Authors>JKorf</Authors>
|
||||
<PackageVersion>2.0.14</PackageVersion>
|
||||
<PackageVersion>2.0.15</PackageVersion>
|
||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||
<PackageProjectUrl>https://github.com/JKorf/CryptoExchange.Net</PackageProjectUrl>
|
||||
<PackageLicenseUrl>https://github.com/JKorf/CryptoExchange.Net/blob/master/LICENSE</PackageLicenseUrl>
|
||||
|
63
CryptoExchange.Net/Interfaces/IRestClient.cs
Normal file
63
CryptoExchange.Net/Interfaces/IRestClient.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CryptoExchange.Net.Interfaces;
|
||||
using CryptoExchange.Net.Objects;
|
||||
using CryptoExchange.Net.RateLimiter;
|
||||
|
||||
namespace CryptoExchange.Net.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for rest API implementations
|
||||
/// </summary>
|
||||
public interface IRestClient: IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The factory for creating requests. Used for unit testing
|
||||
/// </summary>
|
||||
IRequestFactory RequestFactory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// What should happen when hitting a rate limit
|
||||
/// </summary>
|
||||
RateLimitingBehaviour RateLimitBehaviour { get; }
|
||||
|
||||
/// <summary>
|
||||
/// List of active rate limiters
|
||||
/// </summary>
|
||||
IEnumerable<IRateLimiter> RateLimiters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The total amount of requests made
|
||||
/// </summary>
|
||||
int TotalRequestsMade { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The base address of the API
|
||||
/// </summary>
|
||||
string BaseAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a rate limiter to the client. There are 2 choices, the <see cref="RateLimiterTotal"/> and the <see cref="RateLimiterPerEndpoint"/>.
|
||||
/// </summary>
|
||||
/// <param name="limiter">The limiter to add</param>
|
||||
void AddRateLimiter(IRateLimiter limiter);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all rate limiters from this client
|
||||
/// </summary>
|
||||
void RemoveRateLimiters();
|
||||
|
||||
/// <summary>
|
||||
/// Ping to see if the server is reachable
|
||||
/// </summary>
|
||||
/// <returns>The roundtrip time of the ping request</returns>
|
||||
CallResult<long> Ping();
|
||||
|
||||
/// <summary>
|
||||
/// Ping to see if the server is reachable
|
||||
/// </summary>
|
||||
/// <returns>The roundtrip time of the ping request</returns>
|
||||
Task<CallResult<long>> PingAsync();
|
||||
}
|
||||
}
|
45
CryptoExchange.Net/Interfaces/ISocketClient.cs
Normal file
45
CryptoExchange.Net/Interfaces/ISocketClient.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CryptoExchange.Net.Sockets;
|
||||
|
||||
namespace CryptoExchange.Net.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for socket API implementations
|
||||
/// </summary>
|
||||
public interface ISocketClient: IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The factory for creating sockets. Used for unit testing
|
||||
/// </summary>
|
||||
IWebsocketFactory SocketFactory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time in between reconnect attempts
|
||||
/// </summary>
|
||||
TimeSpan ReconnectInterval { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the client should try to auto reconnect when losing connection
|
||||
/// </summary>
|
||||
bool AutoReconnect { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The base address of the API
|
||||
/// </summary>
|
||||
string BaseAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribe from a stream
|
||||
/// </summary>
|
||||
/// <param name="subscription">The subscription to unsubscribe</param>
|
||||
/// <returns></returns>
|
||||
Task Unsubscribe(UpdateSubscription subscription);
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribe all subscriptions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task UnsubscribeAll();
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace CryptoExchange.Net
|
||||
{
|
||||
public abstract class SocketClient: BaseClient
|
||||
public abstract class SocketClient: BaseClient, ISocketClient
|
||||
{
|
||||
#region fields
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user