Exemple #1
0
 internal Task AddSubscription(RedisChannel channel, Action <RedisChannel, RedisValue> handler, CommandFlags flags, object asyncState)
 {
     if (handler != null)
     {
         bool asAsync = !ChannelMessageQueue.IsOneOf(handler);
         lock (subscriptions)
         {
             if (subscriptions.TryGetValue(channel, out Subscription sub))
             {
                 sub.Add(asAsync, handler);
             }
             else
             {
                 sub = new Subscription(asAsync, handler);
                 subscriptions.Add(channel, sub);
                 var task = sub.SubscribeToServer(this, channel, flags, asyncState, false);
                 if (task != null)
                 {
                     return(task);
                 }
             }
         }
     }
     return(CompletedTask <bool> .Default(asyncState));
 }
Exemple #2
0
 internal Task RemoveSubscription(RedisChannel channel, Action <RedisChannel, RedisValue> handler, CommandFlags flags, object asyncState)
 {
     lock (subscriptions)
     {
         bool asAsync = !ChannelMessageQueue.IsOneOf(handler);
         if (subscriptions.TryGetValue(channel, out Subscription sub) && sub.Remove(asAsync, handler))
         {
             subscriptions.Remove(channel);
             var task = sub.UnsubscribeFromServer(channel, flags, asyncState, false);
             if (task != null)
             {
                 return(task);
             }
         }
     }
     return(CompletedTask <bool> .Default(asyncState));
 }
 internal ChannelMessage(ChannelMessageQueue queue, in RedisChannel channel, in RedisValue value)
Exemple #4
0
 internal ChannelMessage(ChannelMessageQueue queue, RedisChannel channel, RedisValue value)
 {
     _queue  = queue;
     Channel = channel;
     Message = value;
 }