public void AddItemToQueue(InputQueueItem inputItem)
 {
     long sequenceNo = requestRingBuffer.Next();
     var entry = requestRingBuffer[sequenceNo];
     entry.RequestId = inputItem.RequestId;
     entry.MethodParameters = inputItem.MethodParameters;
     entry.MethodName = inputItem.MethodName;
     requestRingBuffer.Publish(sequenceNo);
 }
Ejemplo n.º 2
0
        public void AddItemToQueue(InputQueueItem inputItem)
        {
            long sequenceNo = requestRingBuffer.Next();
            var  entry      = requestRingBuffer[sequenceNo];

            entry.RequestId        = inputItem.RequestId;
            entry.MethodParameters = inputItem.MethodParameters;
            entry.MethodName       = inputItem.MethodName;
            requestRingBuffer.Publish(sequenceNo);
        }
        public void OnNext(InputQueueItem data, long sequence, bool endOfBatch)
        {
            try
            {
                string webResult = string.Empty;
                string parameters = "";
                int counter = 0;
                switch (data.MethodName)
                {
                    case BtceTradeApi.BtceCommandUpdateDepth:

                        counter = 0;
                        foreach (var pair in configuration.Pairs)
                        {
                            parameters += pair.ToString();
                            if (counter < configuration.Pairs.Count - 1)
                                parameters += "-";

                            counter++;
                        }

                        webResult = webRequestWrapper.RequestV3("depth", parameters);
                        break;

                    case BtceTradeApi.BtceCommandUpdateMarketTrades:

                        counter = 0;
                        foreach (var pair in configuration.Pairs)
                        {
                            parameters += pair.ToString();
                            if (counter < configuration.Pairs.Count - 1)
                                parameters += "-";

                            counter++;
                        }
                        webResult = webRequestWrapper.RequestV3("trades", parameters);
                        //webResult = webRequestWrapper.RequestData(data.MethodName, data.MethodParameters);
                        break;

                    default:
                        webResult = webRequestWrapper.RequestData(data.MethodName, data.MethodParameters);
                        break;
                }

                requestOutputQueue.AddItemToQueue(new OutputQueueItem
                    {
                        InputQueueItem = data,
                        WebResult = webResult
                    });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }