我正在用poco测试redis客户机。如果注册psubscribe模式后发布,则不调用回调函数。
我正在用poco redis测试代码测试psubscribe。
class RedisSubscriber
{
public:
void onMessage(const void* pSender, RedisEventArgs& args)
{
...
}
void onError(const void* pSender, RedisEventArgs& args)
{
...
}
};
int main()
{
std::string _host = "127.0.0.1";
unsigned _port = 6379;
bool _connected;
Poco::Redis::Client _redis;
_redis.connect(_host, _port);
RedisSubscriber subscriber;
Array subscribe;
subscribe.add("PSUBSCRIBE").add("hi*");
_redis.execute<void>(subscribe);
_redis.flush();
AsyncReader reader(_redis);
reader.redisResponse += Poco::delegate(&subscriber, &RedisSubscriber::onMessage);
reader.redisException += Poco::delegate(&subscriber, &RedisSubscriber::onError);
reader.start();
std::cout << "Sleeping ..." << std::endl;
while (true)
{
Poco::Thread::sleep(100);
}
...
return 0;
}
暂无答案!
目前还没有任何答案,快来回答吧!