コード例 #1
0
 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
ファイル: Events.cs プロジェクト: DTBruce/csredis
 internal RedisSubscriptionChangedEventArgs(RedisSubscriptionChannel response)
 {
     Response = response;
 }