private void Configure(CoinExSocketClientOptions options) { base.Configure(options); baseAddress = options.BaseAddress; subResponseTimeout = (int)Math.Round(options.SubscriptionResponseTimeout.TotalMilliseconds); reconnectInterval = (int)Math.Round(options.ReconnectionInterval.TotalMilliseconds); }
/// <summary> /// Create a new instance of CoinExSocketClient with default options /// </summary> public CoinExSocketClientSpotStreams(Log log, CoinExSocketClient baseClient, CoinExSocketClientOptions options) : base(options, options.SpotStreamsOptions) { _log = log; _options = options; _baseClient = baseClient; }
/// <summary> /// Add the ICoinExClient and ICoinExSocketClient to the sevice collection so they can be injected /// </summary> /// <param name="services">The service collection</param> /// <param name="defaultOptionsCallback">Set default options for the client</param> /// <param name="socketClientLifeTime">The lifetime of the ICoinExSocketClient for the service collection. Defaults to Scoped.</param> /// <returns></returns> public static IServiceCollection AddCoinEx( this IServiceCollection services, Action <CoinExClientOptions, CoinExSocketClientOptions>?defaultOptionsCallback = null, ServiceLifetime?socketClientLifeTime = null) { if (defaultOptionsCallback != null) { var options = new CoinExClientOptions(); var socketOptions = new CoinExSocketClientOptions(); defaultOptionsCallback?.Invoke(options, socketOptions); CoinExClient.SetDefaultOptions(options); CoinExSocketClient.SetDefaultOptions(socketOptions); } services.AddTransient <ICoinExClient, CoinExClient>(); if (socketClientLifeTime == null) { services.AddScoped <ICoinExSocketClient, CoinExSocketClient>(); } else { services.Add(new ServiceDescriptor(typeof(ICoinExSocketClient), typeof(CoinExSocketClient), socketClientLifeTime.Value)); } return(services); }
/// <summary> /// Create a new instance of CoinExSocketClient using provided options /// </summary> /// <param name="options">The options to use for this client</param> public CoinExSocketClient(CoinExSocketClientOptions options) : base("CoinEx", options) { SpotStreams = AddApiClient(new CoinExSocketClientSpotStreams(log, this, options)); AddGenericHandler("Pong", (messageEvent) => { }); SendPeriodic("Ping", TimeSpan.FromMinutes(1), con => new CoinExSocketRequest(NextId(), ServerSubject, PingAction)); }
/// <summary> /// Create a new instance of CoinExSocketClient using provided options /// </summary> /// <param name="options">The options to use for this client</param> public CoinExSocketClient(CoinExSocketClientOptions options) : base(options, options.ApiCredentials == null ? null : new CoinExAuthenticationProvider(options.ApiCredentials)) { Configure(options); AddGenericHandler("Pong", (connection, token) => { }); SendPeriodic(TimeSpan.FromMinutes(1), con => new CoinExSocketRequest(NextId(), ServerSubject, PingAction)); }
private CoinExSocketClient Construct(CoinExSocketClientOptions options = null) { if (options != null) { return(new CoinExSocketClient(options)); } return(new CoinExSocketClient()); }
/// <summary> /// Set the default options to be used when creating new socket clients /// </summary> /// <param name="options">The options to use for new clients</param> public static void SetDefaultOptions(CoinExSocketClientOptions options) { defaultOptions = options; }
/// <summary> /// Create a new instance of CoinExSocketClient using provided options /// </summary> /// <param name="options">The options to use for this client</param> public CoinExSocketClient(CoinExSocketClientOptions options) : base(options, options.ApiCredentials == null ? null : new CoinExAuthenticationProvider(options.ApiCredentials)) { Configure(options); }
private void Configure(CoinExSocketClientOptions options) { subResponseTimeout = (int)Math.Round(options.SubscriptionResponseTimeout.TotalMilliseconds); }