public Subscribe ( string channel, Action |
||
channel | string | /// The channel of the subscription. /// |
subscriptionCallback | Action |
/// The callback method. /// |
return | void |
public void Subscribe(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;
this.Subscriptions.Subscribe(
channel,
(sameAsChannel, data) =>
{
string value = Encoding.UTF8.GetString(data);
subscriptionCallback(value);
});
}
PubSub.PubSubSingleton::Subscribe ( string channel, string key, Action |