mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
mostly changing references, which i hope doesnt break stuff with models (TreeRow, iterators) since they gave me some strange problems in the past
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#pragma once
|
|
#include <ixwebsocket/IXNetSystem.h>
|
|
#include <ixwebsocket/IXWebSocket.h>
|
|
#include <string>
|
|
#include <functional>
|
|
#include <nlohmann/json.hpp>
|
|
#include <sigc++/sigc++.h>
|
|
|
|
class Websocket {
|
|
public:
|
|
Websocket();
|
|
void StartConnection(const std::string &url);
|
|
|
|
void SetUserAgent(std::string agent);
|
|
|
|
bool GetPrintMessages() const noexcept;
|
|
void SetPrintMessages(bool show) noexcept;
|
|
|
|
void Send(const std::string &str);
|
|
void Send(const nlohmann::json &j);
|
|
void Stop();
|
|
void Stop(uint16_t code);
|
|
|
|
private:
|
|
void OnMessage(const ix::WebSocketMessagePtr &msg);
|
|
|
|
ix::WebSocket m_websocket;
|
|
std::string m_agent;
|
|
|
|
public:
|
|
using type_signal_open = sigc::signal<void>;
|
|
using type_signal_close = sigc::signal<void, uint16_t>;
|
|
using type_signal_message = sigc::signal<void, std::string>;
|
|
|
|
type_signal_open signal_open();
|
|
type_signal_close signal_close();
|
|
type_signal_message signal_message();
|
|
|
|
private:
|
|
type_signal_open m_signal_open;
|
|
type_signal_close m_signal_close;
|
|
type_signal_message m_signal_message;
|
|
|
|
bool m_print_messages = true;
|
|
};
|