/// <summary> /// Constructor /// </summary> /// <param name="client">Socket client</param> /// <param name="functionName">Function code, uS is supported</param> /// <param name="callback"></param> /// <param name="param"></param> /// <returns>Connection</returns> public async Task OpenAsync(BittrexWebSocket client, string functionName, Action <string> callback, params object[] param) { if (callback != null) { string functionFullName = null; switch (functionName) { case "uS": functionFullName = "SubscribeToSummaryDeltas"; break; default: throw new InvalidOperationException("Only 'uS' function is supported"); } if (functionFullName != null) { client.AddListener(functionName, callback); bool result = await client.hubProxy.Invoke <bool>(functionFullName, param).ConfigureAwait(false); if (result) { this.client = client; this.callback = callback; this.functionName = functionName; return; } else { client.RemoveListener(functionName, callback); } } } throw new APIException("Unable to open web socket to Bittrex"); }
protected override void OnDispose() { #if HAS_SIGNALR if (webSocket != null) { webSocket.Dispose(); webSocket = null; } #endif }
public BittrexApi(string key, string secret, CancellationToken shutdown, Logger log) : base(key, secret, shutdown, 10, "https://api.bittrex.com/", "https://socket.bittrex.com/signalr") { try { Log = new Logger("BittrexApi", log); WebSocket = new BittrexWebSocket(UrlSocketAddress, shutdown); MarketData = new MarketDataCache(this); } catch { Dispose(); throw; } }