/// <summary>
        /// Subscribes to updates of all markets
        /// </summary>
        /// <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> > SubscribeToAllMarketDeltaStreamAsync(Action <List <BittrexMarketSummary> > onUpdate)
        {
            return(await Task.Run(() =>
            {
                log.Write(LogVerbosity.Debug, $"Going to subscribe to all markets");
                if (!CheckConnection())
                {
                    return ThrowErrorMessage <int>(BittrexErrors.GetError(BittrexErrorKey.CantConnectToServer));
                }

                var registration = new BittrexMarketsAllRegistration()
                {
                    Callback = onUpdate, StreamId = NextStreamId
                };
                lock (registrationLock)
                {
                    registrations.Add(registration);
                    localRegistrations.Add(registration);
                }
                return new BittrexApiResult <int>()
                {
                    Result = registration.StreamId, Success = true
                };
            }).ConfigureAwait(false));
        }
Beispiel #2
0
        /// <summary>
        /// Subscribes to updates of all markets
        /// </summary>
        /// <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> > SubscribeToAllMarketDeltaStreamAsync(Action <List <BittrexMarketSummary> > onUpdate)
        {
            return(await Task.Run(() =>
            {
                log.Write(LogVerbosity.Info, "Subscribing to market deltas for all markets");
                if (!CheckConnection())
                {
                    return new CallResult <int>(0, new CantConnectError());
                }

                var registration = new BittrexMarketsAllRegistration {
                    Callback = onUpdate, StreamId = NextStreamId
                };
                lock (registrationLock)
                {
                    registrations.Add(registration);
                    localRegistrations.Add(registration);
                }
                return new CallResult <int>(registration.StreamId, null);
            }).ConfigureAwait(false));
        }