16 #include <torchcraft/constants.h> 47 Command(
int code, std::string str) : code(code), str(
std::move(str)) {}
48 Command(
int code, std::initializer_list<int>&& args)
49 : code(code), args(args) {}
50 Command(
int code, std::string str, std::initializer_list<int>&& args)
51 : code(code), args(args), str(
std::move(str)) {}
52 Command(
int code, std::string str, std::vector<int>& args)
53 : code(code), args(args), str(
std::move(str)) {}
54 template <
typename... Args>
56 :
Command(code, {a, std::forward<Args>(args)...}) {}
57 template <
typename... Args>
58 Command(
int code, std::string str, Args&&... args)
59 :
Command(code,
std::move(str), {std::forward<Args>(args)...}) {}
82 bool connect(
const std::string& hostname,
int port,
int timeoutMs);
94 bool connect(
const std::string& file_socket,
int timeoutMs);
100 return conn_ !=
nullptr;
120 bool send(
const std::vector<Command>& commands);
127 bool receive(std::vector<std::string>& updates);
131 bool poll(
long timeout = -1);
138 return lastCommands_;
141 return lastCommandsStatus_;
149 bool connect(std::unique_ptr<Connection>&&);
155 std::unique_ptr<Connection> conn_;
160 std::vector<Command> lastCommands_;
161 std::vector<int8_t> lastCommandsStatus_;
std::vector< int > args
Definition: client.h:42
Copyright (c) 2015-present, Facebook, Inc.
Definition: openbwprocess.h:17
Command(int code, std::string str)
Definition: client.h:47
int window_pos[2]
Definition: client.h:30
bool receive(std::vector< std::string > &updates)
Receive a message containing state updates over the established socket connection.
bool connect(const std::string &hostname, int port, int timeoutMs)
Create a socket connection and connect it to an endpoint specified by a TCP address parametrized by a...
bool send(const std::vector< Command > &commands)
Send a message containing commands over the established socket connection.
bool micro_battles
Definition: client.h:31
bool init(std::vector< std::string > &updates, const Options &opts=Options())
Perform handshake over the established connection.
std::string str
Definition: client.h:43
int window_size[2]
Definition: client.h:29
std::vector< Command > lastCommands() const
Definition: client.h:137
Command(int code, std::initializer_list< int > &&args)
Definition: client.h:48
std::string error() const
Definition: client.h:133
Command()
Definition: client.h:45
bool close()
Close the socket connection if it was previously successfully established and destroy the associated ...
Client & operator=(const Client &)=delete
Options()
Definition: client.h:37
Command(int code, std::string str, Args &&...args)
Definition: client.h:58
Command(int code, std::string str, std::initializer_list< int > &&args)
Definition: client.h:50
bool connected() const
Indicates whether the connection was successfully established.
Definition: client.h:99
std::vector< int8_t > lastCommandsStatus() const
Definition: client.h:140
Command(int code)
Definition: client.h:46
bool poll(long timeout=-1)
Blocks until a message is available for receive().
Command(int code, std::string str, std::vector< int > &args)
Definition: client.h:52
State * state() const
Definition: client.h:144
std::string initial_map
Definition: client.h:28
Command(int code, int a, Args &&...args)
Definition: client.h:55
void init()
Definition: cherrypi.cpp:317
std::set< BW::UnitType > only_consider_types
Definition: client.h:35