/// <summary> /// Subscribes to filled orders on a specific market /// </summary> /// <param name="marketName">The name of the market to subscribe on</param> /// <param name="onUpdate">The update event handler</param> /// <returns>ApiResult whether subscription was successful. The Result property contains the Stream Id which can be used to unsubscribe the stream again</returns> public async Task <BittrexApiResult <int> > SubscribeToMarketDeltaStreamAsync(string marketName, Action <BittrexMarketSummary> onUpdate) { return(await Task.Run(() => { log.Write(LogVerbosity.Debug, $"Going to subscribe to {marketName}"); if (!CheckConnection()) { return ThrowErrorMessage <int>(BittrexErrors.GetError(BittrexErrorKey.CantConnectToServer)); } var registration = new BittrexMarketsRegistration() { Callback = onUpdate, MarketName = marketName, StreamId = NextStreamId }; lock (registrationLock) { registrations.Add(registration); localRegistrations.Add(registration); } return new BittrexApiResult <int>() { Result = registration.StreamId, Success = true }; }).ConfigureAwait(false)); }
/// <summary> /// Subscribes to filled orders on a specific market /// </summary> /// <param name="marketName">The name of the market to subscribe on</param> /// <param name="onUpdate">The update event handler</param> /// <returns>ApiResult whether subscription was successful. The Result property contains the Stream Id which can be used to unsubscribe the stream again</returns> public async Task <CallResult <int> > SubscribeToMarketDeltaStreamAsync(string marketName, Action <BittrexMarketSummary> onUpdate) { return(await Task.Run(() => { log.Write(LogVerbosity.Info, $"Subscribing to market deltas for {marketName}"); if (!CheckConnection()) { return new CallResult <int>(0, new CantConnectError()); } var registration = new BittrexMarketsRegistration { Callback = onUpdate, MarketName = marketName, StreamId = NextStreamId }; lock (registrationLock) { registrations.Add(registration); localRegistrations.Add(registration); } return new CallResult <int>(registration.StreamId, null); }).ConfigureAwait(false)); }