(ws) redis_subscribe and redis_publish can take a password + display subscribe response

This commit is contained in:
Benjamin Sergeant
2019-03-26 09:33:22 -07:00
parent 1554c587b3
commit 3388bb50e1
6 changed files with 85 additions and 3 deletions

View File

@ -12,6 +12,7 @@ namespace ix
{
int ws_redis_publish_main(const std::string& hostname,
int port,
const std::string& password,
const std::string& channel,
const std::string& message)
{
@ -22,6 +23,18 @@ namespace ix
return 1;
}
if (!password.empty())
{
std::string authResponse;
if (!redisClient.auth(password, authResponse))
{
std::stringstream ss;
std::cerr << "Cannot authenticated to redis" << std::endl;
return 1;
}
std::cout << "Auth response: " << authResponse << ":" << port << std::endl;
}
std::cerr << "Publishing message " << message
<< " to " << channel << "..." << std::endl;
if (!redisClient.publish(channel, message))