40 lines
663 B
C
40 lines
663 B
C
#include "redisMq.h"
|
|
|
|
void test_func_recv(struct RecvMsg_t *msg)
|
|
{
|
|
if (msg->msg)
|
|
{
|
|
printf("%s,%d,%llu,%s,%d\n", __FUNCTION__, __LINE__, pthread_self(), msg->msg, msg->len);
|
|
freeMsg(msg);
|
|
}
|
|
}
|
|
int main(int argc, char *argv[])
|
|
{
|
|
bool ret = redisSubInit();
|
|
if (!ret)
|
|
{
|
|
printf("Init failed.\n");
|
|
return 0;
|
|
}
|
|
redisRegisterChannelFunc("test-channel",test_func_recv);
|
|
|
|
|
|
ret = redisSubConnect();
|
|
if (!ret)
|
|
{
|
|
printf("Connect failed.\n");
|
|
return 0;
|
|
}
|
|
redisSubscriber("test-channel");
|
|
|
|
while (true)
|
|
{
|
|
sleep(1);
|
|
}
|
|
|
|
redisSubDisconnect();
|
|
redisSubUninit();
|
|
|
|
return 0;
|
|
}
|