Skip to content

Commit

Permalink
feat: update default IP and port values in UDPServer and improve help…
Browse files Browse the repository at this point in the history
… message formatting
  • Loading branch information
MasterLaplace committed Dec 9, 2024
1 parent 081826f commit d95a612
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions Flakkari/ParseArgument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ParseArgument::ParseArgument(int ac, const char *av[])
if (_gameDir.empty())
GetGameDirEnv();

if (_ip.empty())
_ip = "localhost";

if (_port == 0)
Expand Down
12 changes: 6 additions & 6 deletions Flakkari/ParseArgument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ class ParseArgument {

static constexpr const char *HELP_MESSAGE =
"Usage: ./r-type_server <gameDir> <ip> <port>\n"
" <gameDir> The directory of the games folder\n"
" <ip> The ip to bind the server to (default: localhost)\n"
" <port> The port to bind the server to (default: 8081)\n"
" -d|--default Use default values (Games, localhost, 8081)\n"
" -v|--version Display the version of the Flakkari Library\n"
" -h|--help Display this help message\n\n"
" -gameDir <gameDir> The directory of the games folder\n"
" -ip <ip> The ip to bind the server to (default: localhost)\n"
" -port <port> The port to bind the server to (default: 8081)\n"
" -d|--default Use default values (Games, localhost, 8081)\n"
" -v|--version Display the version of the Flakkari Library\n"
" -h|--help Display this help message\n\n"
"Example: ./r-type_server Games localhost 8081\n\n"
"More information at https://github.com/MasterLaplace/Falkkari\n"
"Flakkari Library v" FLAKKARI_VERSION_STRING " - © 2024 MasterLaplace\n";
Expand Down
2 changes: 1 addition & 1 deletion Flakkari/Server/UDPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool UDPServer::handleTimeout(int event)
{
if (event != 0)
return false;
FLAKKARI_LOG_DEBUG(XSTR(IO_SELECTED) " timed out");
FLAKKARI_LOG_DEBUG(LPL_TOSTRING(IO_SELECTED) " timed out");
ClientManager::GetInstance().checkInactiveClients();
ClientManager::UnlockInstance();
return true;
Expand Down
12 changes: 3 additions & 9 deletions Flakkari/Server/UDPServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,17 @@ namespace Flakkari {
# define STDIN_FILENO _fileno(stdin)
#endif

#define STR(x) #x
#define XSTR(x) STR(x)

/**
* @brief UDP Server class that handles incoming packets and clients
*
* @details This class is the main class of the server, it handles incoming
* packets and clients, it also handles the client's timeout and disconnection
* @see ClientManager
* @see Network::Socket
* @see Network::PPOLL
*
* @example "Flakkari/Server/UDPServer.cpp"
* @code
* #include "UDPServer.hpp"
*
* Flakkari::UDPServer server("localhost", 8080);
* Flakkari::UDPServer server("Games", "localhost", 8081);
* return server.run();
* @endcode
*/
Expand All @@ -59,9 +53,9 @@ class UDPServer {
*
* @param gameDir The directory of the games folder
* @param ip The ip to bind the server to (default: localhost)
* @param port The port to bind the server to (default: 8080)
* @param port The port to bind the server to (default: 8081)
*/
UDPServer(const std::string &gameDir, const std::string &ip = "localhost", unsigned short port = 8080);
UDPServer(const std::string &gameDir, const std::string &ip = "localhost", unsigned short port = 8081);
~UDPServer();

/**
Expand Down

0 comments on commit d95a612

Please sign in to comment.