-
Notifications
You must be signed in to change notification settings - Fork 16
/
rconsrv.h
66 lines (52 loc) · 2.15 KB
/
rconsrv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef RCONSRV_H
#define RCONSRV_H
#include "noncopyable.h"
#include "logger.h"
#include <list>
#include <set>
#include <giomm/asyncresult.h>
#include <giomm/socketconnection.h>
#include <giomm/socketservice.h>
#include <glibmm/refptr.h>
#include <sigc++/trackable.h>
#include <referee.pb.h>
class Configuration;
class GameController;
class SSL_RefereeRemoteControlRequest;
class SSL_RefereeRemoteControlReply;
class RConServer : public NonCopyable, public sigc::trackable {
public:
RConServer(GameController &controller);
~RConServer();
Logger &logger;
std::set<SSL_Referee_Command> commands_on_hold;
void set_commands_on_hold(const std::set<SSL_Referee_Command> &commands);
private:
class Connection : public NonCopyable, public sigc::trackable {
public:
Connection(RConServer &server, const Glib::RefPtr<Gio::SocketConnection> &sock);
~Connection();
bool paused;
void set_connection_list_iterator(std::list<Connection>::iterator iter);
void finished_read_data(bool ok);
private:
RConServer &server;
Glib::RefPtr<Gio::SocketConnection> sock;
std::list<Connection>::iterator connection_list_iterator;
uint32_t length;
std::vector<unsigned char> buffer;
void start_read_length();
void finished_read_length(bool ok);
void finished_write_reply(bool ok);
void execute_request(const SSL_RefereeRemoteControlRequest &request, SSL_RefereeRemoteControlReply &reply, bool &delayRequest);
void start_read_fully(void *buffer, std::size_t length, const sigc::slot<void, bool> &slot);
void finished_read_fully_partial(Glib::RefPtr<Gio::AsyncResult> &result, void *rptr, std::size_t left, const sigc::slot<void, bool> &slot);
void start_write_fully(const void *data, std::size_t length, const sigc::slot<void, bool> &slot);
void finished_write_fully_partial(Glib::RefPtr<Gio::AsyncResult> &result, const void *wptr, std::size_t left, const sigc::slot<void, bool> &slot);
};
GameController &controller;
Glib::RefPtr<Gio::SocketService> listener;
std::list<Connection> connections;
bool on_incoming(const Glib::RefPtr<Gio::SocketConnection> &sock, const Glib::RefPtr<Glib::Object> &);
};
#endif