]> git.sesse.net Git - ultimatescore/blob - client/ws_server.h
Make the roster scripts executable.
[ultimatescore] / client / ws_server.h
1 #ifndef _WS_SERVER_H
2 #define _WS_SERVER_H 1
3
4 #include <functional>
5 #include <mutex>
6 #include <string>
7 #include <thread>
8 #include <unordered_set>
9 #include <vector>
10
11 #include <QObject>
12
13 class QWebSocket;
14 class QWebSocketServer;
15
16 class WSServer : public QObject {
17         Q_OBJECT
18
19 public:
20         WSServer(const std::string &host, int port);
21
22         void set_connection_callback(const std::function<void(bool)> &callback);
23         void send_command(const std::string &cmd);
24         void change_port(int port);
25
26 private slots:
27         void on_new_connection();
28         void disconnected();
29
30 private:
31         void thread_func();
32
33         std::function<void(bool)> connection_callback;
34
35         QWebSocketServer *ws_server;
36         std::unordered_set<QWebSocket *> clients;
37 };
38
39 #endif  // !defined(_WS_SERVER_H)