Need this to implement execution at crypto exchanges (beginning with Binance and OKX)
33 lines
764 B
C++
33 lines
764 B
C++
#pragma once
|
|
|
|
#include "lib/utils/Delegate.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <websocketpp/config/core_client.hpp>
|
|
#include <websocketpp/message_buffer/message.hpp>
|
|
|
|
namespace bts::websocket {
|
|
|
|
class WebsocketClientConfig;
|
|
|
|
class WebsocketClient {
|
|
public:
|
|
WebsocketClient(std::string url, std::uint32_t timeout_secs = 20);
|
|
~WebsocketClient();
|
|
|
|
using MessageHandler = bts::core::Delegate<void(const std::string &)>;
|
|
|
|
void connect(const std::map<std::string, std::string> &headers = {});
|
|
void disconnect();
|
|
bool is_connected() const;
|
|
MessageHandler &message_handler();
|
|
websocketpp::lib::error_code send_text(const std::string &text);
|
|
|
|
private:
|
|
struct PImpl;
|
|
std::unique_ptr<PImpl> me_;
|
|
};
|
|
|
|
} // namespace bts::websocket
|