12#ifndef MINESERVER_NETWORK_H
13#define MINESERVER_NETWORK_H
154 return address ==
"127.0.0.1" || address ==
"localhost";
199 bool bind(
const char *address,
int port)
const;
Network POSIX Client.
Definition network.h:42
~ClientSocket()=default
Destroy the Client Socket object.
ClientSocket(socket_t client, char *addr)
Construct a new Client Socket object.
Definition network.cpp:146
ssize_t write(const std::byte *buffer, size_t len) const
Writes to the socket.
Definition network.cpp:206
bool isLocal() const
Checks whether the connection is a local one.
Definition network.h:152
size_t getAvailableBytes() const
Get the number of available bytes.
Definition network.cpp:224
bool isValid() const
Whether the connection is valid.
Definition network.cpp:236
bool connect(const char *address, int port) const
Connects to an address on a certain port.
Definition network.cpp:173
ssize_t read(std::byte *buffer, size_t len) const
Reads from the socket.
Definition network.cpp:192
void close() const
Closes the connection.
Definition network.cpp:215
std::string getAddress() const
Get the Address of the client.
Definition network.h:141
socket_t getHandle() const
Get the Handle of the socket.
Definition network.h:131
MinecraftUUID compliant data holder.
Definition uuid.h:27
Network POSIX Server.
Definition network.h:164
static bool init()
Inits the POSIX API.
Definition network.cpp:100
bool bind(const char *address, int port) const
Binds the server to port / address.
Definition network.cpp:38
ServerSocket()
Construct a new empty Server Socket object.
void close() const
Closes the connection.
Definition network.cpp:91
static bool cleanup()
Cleansup the POSIX API.
Definition network.cpp:137
ClientSocket accept() const
Accepts a new client.
Definition network.cpp:73
void start(unsigned int backlog) const
Starts the server.
Definition network.cpp:68
~ServerSocket()=default
Destroy the Server Socket object.
constexpr std::string_view type_name()
Gets the name of the type paramater.
Definition event.h:56
The Mojang API holder.
Definition network.h:258
HasJoinedResponse hasJoined(const std::string &username, const std::string &serverId, const std::string &ip="")
Checks whether the player has joined the server.
Definition network.cpp:246
Reponse for hasJoined endpoint.
Definition network.h:264
MinecraftUUID id
MinecraftUUID of the player.
Definition network.h:274
std::string name
Name of the player.
Definition network.h:269
The file containing MinecraftUUID logic.