Synchronous subscriber using Redis Publisher/Subscriber Package.
More...
#include <RedisPubSub.h>
Synchronous subscriber using Redis Publisher/Subscriber Package.
RedisSyncSubscriber() inherits from RedisSubscriber() and subscribes data in Redis server(broker).
RedisSyncSubscriber::RedisSyncSubscriber |
( |
| ) |
|
RedisSyncSubscriber::RedisSyncSubscriber |
( |
const string & |
host, |
|
|
int32_t |
port = 6379 |
|
) |
| |
Constructor.
- Parameters
-
[in] | host | Host IP address of the broker. |
[in] | port | Port number of the broker. |
RedisSyncSubscriber::~RedisSyncSubscriber |
( |
| ) |
|
|
virtual |
int32_t RedisSyncSubscriber::get |
( |
string & |
name, |
|
|
char * |
target_buf, |
|
|
int32_t & |
size, |
|
|
int32_t |
timeout = 2000 |
|
) |
| |
Get data from the Redis broker (sync).
- Parameters
-
[out] | name | Name of data |
[out] | target_buf | Target buffer |
[out] | size | Size of data |
[in] | timeout | Timeout milli-seconds |
- Return values
-
1 | Time out |
0 | Success |
-1 | no Redis context(empty) |
-2 | redisSetTimeout() error |
-3 | Redis reply context was null |
-4 | Redis reply error |
< replace the object
int32_t RedisSyncSubscriber::getChannels |
( |
string |
name, |
|
|
vector< string > & |
vec |
|
) |
| |
Get name of channels from the Redis broker (sync).
This method should be called before subscribe() or after unsubscribe().
- Parameters
-
[in] | name | Name of data(allow asterisk like ml*) |
[out] | vec | list of the name |
- Return values
-
0 | Success |
-1 | no Redis context(empty) |
-2 | redisCommand was not executed correctly |
-3 | redisCommand error |
int32_t RedisSyncSubscriber::init |
( |
| ) |
|
Initialize subscriber as synchronous mode and connect to the broker.
- Return values
-
0 | Success |
-1 | Redis context was not allocated |
-2 | Redis context has some error condition |
void RedisSubscriber::setHost |
( |
const string & |
host, |
|
|
int32_t |
port |
|
) |
| |
|
inherited |
Set host address of the broker.
- Parameters
-
[in] | host | Host IP address of the broker. |
[in] | port | Port number of the broker. |
int32_t RedisSyncSubscriber::subscribe |
( |
const string & |
name | ) |
|
Subscribe data from the Redis broker (sync).
- Parameters
-
- Return values
-
0 | Success |
-1 | no Redis context(empty) |
-2 | redisCommand was not executed correctly |
-3 | redisCommand error |
int32_t RedisSyncSubscriber::unsubscribe |
( |
const string & |
name | ) |
|
Unsubscribe data from the Redis broker (sync).
- Parameters
-
- Return values
-
0 | Success |
-1 | no Redis context(empty) |
-2 | redisCommand was not executed correctly |
-3 | redisCommand error |
std::shared_ptr<redisContext> RedisSubscriber::m_context |
|
protectedinherited |
string RedisSubscriber::m_host |
|
protectedinherited |
int32_t RedisSubscriber::m_port |
|
protectedinherited |
The documentation for this class was generated from the following files: