BB.Caching.Redis.PubSub.PubSubSingleton.SubscribeAsync C# (CSharp) Méthode

SubscribeAsync() public méthode

Creates a subscription to a channel.
public SubscribeAsync ( string channel, Action subscriptionCallback ) : Task
channel string /// The channel of the subscription. ///
subscriptionCallback Action /// The callback method. ///
Résultat Task
            public Task SubscribeAsync(string channel, Action<string> subscriptionCallback)
            {
                // Check to make sure we're not re-creating an existing subscription first.
                if (this.ActiveKeylessSubscriptions.ContainsKey(channel))
                {
                    throw new ChannelAlreadySubscribedException(
                        string.Format("subscription to channel {0} already exists", channel));
                }

                // Let's add this subscription to our cache. We'll need to remember it so that we can re-subscribe
                // if we lose our connection at any point.
                this.ActiveKeylessSubscriptions[channel] = subscriptionCallback;
                return this.Subscriptions.SubscribeAsync(
                    channel,
                    (sameAsChannel, data) =>
                    {
                        string value = Encoding.UTF8.GetString(data);
                        subscriptionCallback(value);
                    });
            }

Same methods

PubSub.PubSubSingleton::SubscribeAsync ( string channel, string key, Action subscriptionCallback ) : Task