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);
});
}