IXWebSocket/ws/IXRedisClient.h

41 lines
1.0 KiB
C
Raw Normal View History

/*
* IXRedisClient.h
* Author: Benjamin Sergeant
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
*/
#pragma once
#include <functional>
2019-05-30 17:46:50 +02:00
#include <memory>
namespace ix
{
class Socket;
2019-05-30 17:46:50 +02:00
class RedisClient
{
public:
using OnRedisSubscribeResponseCallback = std::function<void(const std::string&)>;
using OnRedisSubscribeCallback = std::function<void(const std::string&)>;
RedisClient() = default;
~RedisClient() = default;
2019-05-30 17:46:50 +02:00
bool connect(const std::string& hostname, int port);
2019-05-30 17:46:50 +02:00
bool auth(const std::string& password, std::string& response);
2019-05-30 17:46:50 +02:00
bool publish(const std::string& channel, const std::string& message, std::string& errMsg);
bool subscribe(const std::string& channel,
const OnRedisSubscribeResponseCallback& responseCallback,
const OnRedisSubscribeCallback& callback);
private:
std::string writeString(const std::string& str);
std::shared_ptr<Socket> _socket;
};
2019-05-30 17:46:50 +02:00
} // namespace ix