Files
spark/src/lib/io/websocket/websocket_client.h
T
John Colvin ee4c28ed41 Port ws client over from cme-websocket-connector
Need this to implement execution at crypto exchanges (beginning with
Binance and OKX)
2024-12-04 16:56:46 +00:00

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