New Managed Pub/Sub Serverのドキュメントでは、pubsubserver の初期化でチャネルをサブスクライブする方法が示されています。しかし、プログラムの後半で必要になったときに、特定のチャンネルの登録を解除するにはどうすればよいでしょうか?
私のコード:
using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace va.communication
{
class Program
{
static void Main(string[] args)
{
var clientsManager = new PooledRedisClientManager();
//subscribe to channels 'messages' and 'queue'
var redisPubSub = new RedisPubSubServer(clientsManager, "messages","queue")
{
OnUnSubscribe = (channel) =>
{
Console.WriteLine("Unsubscribed from channel '{0}'", channel);
},
OnMessage = (channel, msg) =>
{
Console.WriteLine("Received '{0}' from channel '{1}'", msg, channel);
}
};
redisPubSub.Start();
//...
//other code which takes ~5s after which i want to unsubscribe from 'messages'
Thread.Sleep(5000);
//...
//no longer require channel 'messages'. what to do here?
while (true) ;//continue with other code
}
}
}