/// <summary>
        /// Serializes request and sends message via websocket communicator.
        /// It logs and re-throws every exception.
        /// </summary>
        /// <param name="request">Request/message to be sent</param>
        public void Send <T>(T request)
        {
            try
            {
                BnbValidations.ValidateInput(request, nameof(request));

                var serialized = BinanceJsonSerializer.Serialize(request);
                _communicator.Send(serialized);
            }
            catch (Exception e)
            {
                Log.Error(e, L($"Exception while sending message '{request}'. Error: {e.Message}"));
                throw;
            }
        }
Exemplo n.º 2
0
        private bool HandleObjectMessage(string msg)
        {
            var response = BinanceJsonSerializer.Deserialize <JObject>(msg);

            // ********************
            // ADD OBJECT HANDLERS BELOW
            // ********************

            return

                (TradeResponse.TryHandle(response, Streams.TradesSubject) ||
                 AggregatedTradeResponse.TryHandle(response, Streams.TradeBinSubject) ||
                 OrderBookPartialResponse.TryHandle(response, Streams.OrderBookPartialSubject) ||
                 OrderBookDiffResponse.TryHandle(response, Streams.OrderBookDiffSubject)
                );
        }