public AlterDiceSocketClient(string clientName, SocketClientOptions exchangeOptions, AuthenticationProvider authenticationProvider) : base(clientName, exchangeOptions, authenticationProvider) { //_socketIo = IO.Socket("https://socket.alterdice.com"); //_socketIo.Connect(); _socketIo = new SocketIO("https://socket.alterdice.com/"); _socketIo.OnConnected += _socketIo_OnConnected; _socketIo.OnError += _socketIo_OnError; _socketIo.OnReceivedEvent += _socketIo_OnReceivedEvent; _socketIo.OnDisconnected += _socketIo_OnDisconnected; _socketIo.On("hi", response => { string text = response.GetValue <string>(); Console.WriteLine(text); }); _socketIo.OnConnected += async(sender, e) => { await _socketIo.EmitAsync("hi", ".net core"); Console.WriteLine(e.ToString()); }; _socketIo.On("message", (data) => { Console.WriteLine(data.ToString()); var t = JsonConvert.DeserializeObject <List <List <AlterDiceSocketOrderBookUpdateEvent> > >(data.ToString()); OnOrderBookUpdate?.Invoke(t[0][0]); }); _socketIo.ConnectAsync().GetAwaiter().GetResult(); }
/// <summary> /// Configure the client using the provided options /// </summary> /// <param name="exchangeOptions">Options</param> protected void Configure(SocketClientOptions exchangeOptions) { AutoReconnect = exchangeOptions.AutoReconnect; ReconnectInterval = exchangeOptions.ReconnectInterval; ResponseTimeout = exchangeOptions.SocketResponseTimeout; SocketNoDataTimeout = exchangeOptions.SocketNoDataTimeout; SocketCombineTarget = exchangeOptions.SocketSubscriptionsCombineTarget ?? 1; }
/// <summary> /// Create a socket client /// </summary> /// <param name="exchangeOptions">Client options</param> /// <param name="authenticationProvider">Authentication provider</param> protected SocketClient(SocketClientOptions exchangeOptions, AuthenticationProvider?authenticationProvider) : base(exchangeOptions, authenticationProvider) { if (exchangeOptions == null) { throw new ArgumentNullException(nameof(exchangeOptions)); } AutoReconnect = exchangeOptions.AutoReconnect; ReconnectInterval = exchangeOptions.ReconnectInterval; ResponseTimeout = exchangeOptions.SocketResponseTimeout; SocketNoDataTimeout = exchangeOptions.SocketNoDataTimeout; SocketCombineTarget = exchangeOptions.SocketSubscriptionsCombineTarget ?? 1; }
/// <summary> /// ctor /// </summary> /// <param name="exchangeName">The name of the exchange this client is for</param> /// <param name="exchangeOptions">The options for this client</param> /// <param name="authenticationProvider">The authentication provider for this client (can be null if no credentials are provided)</param> protected SocketClient(string exchangeName, SocketClientOptions exchangeOptions, AuthenticationProvider?authenticationProvider) : base(exchangeName, exchangeOptions, authenticationProvider) { if (exchangeOptions == null) { throw new ArgumentNullException(nameof(exchangeOptions)); } AutoReconnect = exchangeOptions.AutoReconnect; ReconnectInterval = exchangeOptions.ReconnectInterval; ResponseTimeout = exchangeOptions.SocketResponseTimeout; SocketNoDataTimeout = exchangeOptions.SocketNoDataTimeout; SocketCombineTarget = exchangeOptions.SocketSubscriptionsCombineTarget ?? 1; MaxReconnectTries = exchangeOptions.MaxReconnectTries; MaxResubscribeTries = exchangeOptions.MaxResubscribeTries; MaxConcurrentResubscriptionsPerSocket = exchangeOptions.MaxConcurrentResubscriptionsPerSocket; }
public AlterDiceSocketClient(string clientName, SocketClientOptions exchangeOptions, AuthenticationProvider authenticationProvider) : base(clientName, exchangeOptions, authenticationProvider) { _socketIo = new SocketIO("https://socket.alterdice.com/", new SocketIOOptions() { EIO = 3, ConnectionTimeout = TimeSpan.FromSeconds(20), Reconnection = true }); _socketIo.OnPong += _socketIo_OnPong; _socketIo.OnConnected += _socketIo_OnConnected; _socketIo.OnError += _socketIo_OnError; _socketIo.OnDisconnected += _socketIo_OnDisconnected; _socketIo.OnConnected += async(sender, e) => { log.Write(LogLevel.Debug, $"{DateTime.UtcNow}: connected"); }; _socketIo.On("message", (data) => { OnOrderBookMessage(data); }); _socketIo.ConnectAsync().GetAwaiter().GetResult(); }
public TestSocketClient(SocketClientOptions exchangeOptions) : base("test", exchangeOptions, exchangeOptions.ApiCredentials == null ? null : new TestAuthProvider(exchangeOptions.ApiCredentials)) { SocketFactory = new Mock <IWebsocketFactory>().Object; Mock.Get(SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny <Log>(), It.IsAny <string>())).Returns(new TestSocket()); }
protected SocketClient(SocketClientOptions exchangeOptions, AuthenticationProvider authenticationProvider) : base(exchangeOptions, authenticationProvider) { Configure(exchangeOptions); }
/// <summary> /// Configure the client using the provided options /// </summary> /// <param name="exchangeOptions">Options</param> protected void Configure(SocketClientOptions exchangeOptions) { ReconnectInterval = exchangeOptions.ReconnectInterval; }