--- /dev/null
+#ifndef _WS_SERVER_H
+#define _WS_SERVER_H 1
+
+#include <functional>
+#include <mutex>
+#include <string>
+#include <thread>
+#include <unordered_set>
+#include <vector>
+
+#include <QObject>
+
+class QWebSocket;
+class QWebSocketServer;
+
+class WSServer : public QObject {
+ Q_OBJECT
+
+public:
+ WSServer(const std::string &host, int port);
+
+ void add_init_command(const std::string &cmd);
+ void set_connection_callback(const std::function<void(bool)> &callback);
+ void send_command(const std::string &cmd);
+ void change_port(int port);
+
+private slots:
+ void on_new_connection();
+ void disconnected();
+
+private:
+ void thread_func();
+
+ std::vector<std::string> init_commands;
+ std::function<void(bool)> connection_callback;
+
+ QWebSocketServer *ws_server;
+ std::unordered_set<QWebSocket *> clients;
+};
+
+#endif // !defined(_WS_SERVER_H)