Example #1
0
        private void OnArrayMessage(string msg)
        {
            var parsed = BitfinexSerialization.Deserialize <JArray>(msg);

            if (parsed.Count() < 2)
            {
                Log.Warn(L("Invalid message format, too low items"));
                return;
            }

            var channelId = (int)parsed[0];

            if (!_channelIdToHandler.ContainsKey(channelId))
            {
                Log.Debug($"Unrecognized channel id '{channelId}', ignoring..");
                return;
            }

            _channelIdToHandler[channelId](parsed, Configuration);
        }
        public void OnObjectMessage(string msg)
        {
            var parsed = BitfinexSerialization.Deserialize <MessageBase>(msg);

            switch (parsed.Event)
            {
            case MessageType.Pong:
                PongResponse.Handle(msg, _streams.PongSubject);
                break;

            case MessageType.Error:
                ErrorResponse.Handle(msg, _streams.ErrorSubject);
                break;

            case MessageType.Info:
                InfoResponse.Handle(msg, _streams.InfoSubject);
                break;

            case MessageType.Auth:
                AuthenticationResponse.Handle(msg, _streams.AuthenticationSubject);
                break;

            case MessageType.Conf:
                ConfigurationResponse.Handle(msg, _streams.ConfigurationSubject);
                break;

            case MessageType.Subscribed:
                OnSubscription(BitfinexSerialization.Deserialize <SubscribedResponse>(msg));
                break;

            case MessageType.Unsubscribed:
                UnsubscribedResponse.Handle(msg, _streams.UnsubscriptionSubject);
                break;
                //default:
                //    Log.Warning($"Missing handler for public stream, data: '{msg}'");
                //    break;
            }
        }