Пример #1
0
        internal IEnumerable <IRedisChannel> GetSubscribedTo(RESPArray message)
        {
            Contract.Assert(message.Any(), "Empty RESPArray");

            var operation = message.ElementAt <RESPBulkString>(0).Value.ToUpperInvariant();

            if (!IsSubscriptionMessage(operation))
            {
                return(Enumerable.Empty <IRedisChannel>());
            }

            var aggregator = operation.Equals("MESSAGE", StringComparison.Ordinal) ? _subscriptions : _psubscriptions;

            return(aggregator.GetChannels(message.ElementAt <RESPBulkString>(1).Value));
        }
        internal void Acknowledge(RESPArray response)
        {
            Contract.Assert(response.Any(), "Empty RESPArray");

            var operation = response.ElementAt <RESPBulkString>(0).Value.ToUpperInvariant();
            var key       = response.ElementAt <RESPBulkString>(1).Value;

            switch (operation)
            {
            case "SUBSCRIBE":
            case "PSUBSCRIBE":
                AcknowledgeSubscription(key);
                break;

            case "UNSUBSCRIBE":
            case "PUNSUBSCRIBE":
                AcknowledgeUnsubscription(key);
                break;
            }
        }