void OnReceivedChannel(RedisSubscriptionChannel channel)
 {
     _count = channel.Count;
     if (Changed != null)
     {
         Changed(this, new RedisSubscriptionChangedEventArgs(channel));
     }
 }
Пример #2
0
        public void HandleSubscription(RedisSubscription command)
        {
            _connection.Write(command.Command, command.Arguments);
            if (!IsSubscribed)
            {
                using (new ActivityTracer("Handle subscriptions"))
                {
                    IsSubscribed = true;
                    while (true)
                    {
                        var resp = _connection.Read(command.Parser);
                        switch (resp.Type)
                        {
                        case RedisSubscriptionResponseType.Subscribe:
                        case RedisSubscriptionResponseType.PSubscribe:
                        case RedisSubscriptionResponseType.Unsubscribe:
                        case RedisSubscriptionResponseType.PUnsubscribe:
                            RedisSubscriptionChannel channel = resp as RedisSubscriptionChannel;
                            Count = channel.Count;
                            if (SubscriptionChanged != null)
                            {
                                SubscriptionChanged(this, new RedisSubscriptionChangedEventArgs(channel));
                            }
                            break;

                        case RedisSubscriptionResponseType.Message:
                        case RedisSubscriptionResponseType.PMessage:
                            RedisSubscriptionMessage message = resp as RedisSubscriptionMessage;
                            if (SubscriptionReceived != null)
                            {
                                SubscriptionReceived(this, new RedisSubscriptionReceivedEventArgs(message));
                            }
                            break;
                        }
                        if (Count == 0)
                        {
                            break;
                        }
                    }
                    IsSubscribed = false;
                }
            }
        }
Пример #3
0
 void OnReceivedChannel(RedisSubscriptionChannel channel)
 {
     _count = channel.Count;
     Changed?.Invoke(this, new RedisSubscriptionChangedEventArgs(channel));
 }
Пример #4
0
 internal RedisSubscriptionChangedEventArgs(RedisSubscriptionChannel response)
 {
     Response = response;
 }