mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
rename client header files
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#ifndef WEB_SOCKET_WRAPPER_H
|
||||
#define WEB_SOCKET_WRAPPER_H
|
||||
|
||||
#include <QTimer>
|
||||
#include <QtWebSockets/QWebSocket>
|
||||
#include <nlohmann/json.hpp>
|
||||
using json = nlohmann::json;
|
||||
|
||||
class Web_socket_wrapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Command
|
||||
{
|
||||
get_UI_element,
|
||||
get_UI_elements,
|
||||
switch_simulator,
|
||||
get_active_simulator_name,
|
||||
get_simulators,
|
||||
end,
|
||||
begin = 0
|
||||
};
|
||||
|
||||
enum class Event
|
||||
{
|
||||
clicked,
|
||||
value_changed,
|
||||
text_changed,
|
||||
selected,
|
||||
can_send,
|
||||
can_clear,
|
||||
ui_changed,
|
||||
end,
|
||||
begin = 0
|
||||
};
|
||||
|
||||
public:
|
||||
explicit Web_socket_wrapper(const QUrl &url, QObject *parent = nullptr);
|
||||
~Web_socket_wrapper();
|
||||
void send_command(Command command, size_t id = 0);
|
||||
void send_command(Command command, QString id);
|
||||
void send_event(Event event, size_t id);
|
||||
void send_event(Event event, size_t id, double val);
|
||||
void send_event(Event event, size_t id, QString val);
|
||||
void send_event(Event event, size_t id, uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
void close();
|
||||
|
||||
Q_SIGNALS:
|
||||
void on_connected();
|
||||
void on_closed();
|
||||
void on_command_cb(json &data);
|
||||
void on_event_cb(json &data);
|
||||
|
||||
private Q_SLOTS:
|
||||
void m_on_connected();
|
||||
void m_on_received(QString message);
|
||||
void m_on_pong(quint64 elapsedTime);
|
||||
void m_on_pong_timeout();
|
||||
|
||||
private:
|
||||
bool m_connected = false;
|
||||
QWebSocket *m_web_socket;
|
||||
QTimer *m_ping_timer;
|
||||
QTimer *m_pong_timer;
|
||||
};
|
||||
|
||||
#endif // WEB_SOCKET_WRAPPER_H
|
||||
Reference in New Issue
Block a user