mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-14 07:01:46 +00:00
101 lines
3.6 KiB
C#
101 lines
3.6 KiB
C#
using CryptoExchange.Net.RateLimiting;
|
|
using CryptoExchange.Net.RateLimiting.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace CryptoExchange.Net.Objects.Sockets
|
|
{
|
|
/// <summary>
|
|
/// Parameters for a websocket
|
|
/// </summary>
|
|
public class WebSocketParameters
|
|
{
|
|
/// <summary>
|
|
/// The uri to connect to
|
|
/// </summary>
|
|
public Uri Uri { get; set; }
|
|
|
|
/// <summary>
|
|
/// Headers to send in the connection handshake
|
|
/// </summary>
|
|
public IDictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// Cookies to send in the connection handshake
|
|
/// </summary>
|
|
public IDictionary<string, string> Cookies { get; set; } = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// The fixed time to wait between reconnect attempts, only used when `ReconnectPolicy` is set to `ReconnectPolicy.ExponentialBackoff`
|
|
/// </summary>
|
|
public TimeSpan ReconnectInterval { get; set; } = TimeSpan.FromSeconds(5);
|
|
|
|
/// <summary>
|
|
/// Reconnect policy
|
|
/// </summary>
|
|
public ReconnectPolicy ReconnectPolicy { get; set; } = ReconnectPolicy.FixedDelay;
|
|
|
|
/// <summary>
|
|
/// Proxy for the connection
|
|
/// </summary>
|
|
public ApiProxy? Proxy { get; set; }
|
|
|
|
/// <summary>
|
|
/// The maximum time of no data received before considering the connection lost and closing/reconnecting the socket
|
|
/// </summary>
|
|
public TimeSpan? Timeout { get; set; }
|
|
|
|
/// <summary>
|
|
/// Interval at which to send ping frames
|
|
/// </summary>
|
|
public TimeSpan? KeepAliveInterval { get; set; }
|
|
|
|
/// <summary>
|
|
/// Timeout for keep alive response messages
|
|
/// </summary>
|
|
public TimeSpan? KeepAliveTimeout { get; set; }
|
|
|
|
/// <summary>
|
|
/// The rate limiter for the socket connection
|
|
/// </summary>
|
|
public IRateLimitGate? RateLimiter { get; set; }
|
|
/// <summary>
|
|
/// What to do when rate limit is reached
|
|
/// </summary>
|
|
public RateLimitingBehaviour RateLimitingBehavior { get; set; }
|
|
|
|
/// <summary>
|
|
/// A delegate receiving the request definition and the request weight that can be used to determine whether a request should be admitted or rejected based
|
|
/// on the request definition and the current rate limit usage ratio. This allows for custom rate limiting logic to be implemented.
|
|
/// </summary>
|
|
public Func<RequestDefinition, int, RateLimitAdmission?>? RateLimitAdmissionCallbackOptions { get; set; }
|
|
|
|
/// <summary>
|
|
/// A delegate for retrieving the current rate limit admission decision for a specific request. This allows for custom rate limiting logic to be implemented.
|
|
/// </summary>
|
|
public Func<RateLimitAdmission?>? RateLimitAdmissionCallbackRequest { get; set; }
|
|
|
|
/// <summary>
|
|
/// Encoding for sending/receiving data
|
|
/// </summary>
|
|
public Encoding Encoding { get; set; } = Encoding.UTF8;
|
|
|
|
/// <summary>
|
|
/// The buffer size to use for receiving data
|
|
/// </summary>
|
|
public int? ReceiveBufferSize { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
/// <param name="uri">Uri</param>
|
|
/// <param name="policy">Reconnect policy</param>
|
|
public WebSocketParameters(Uri uri, ReconnectPolicy policy)
|
|
{
|
|
Uri = uri;
|
|
ReconnectPolicy = policy;
|
|
}
|
|
}
|
|
}
|