diff --git a/PlayerTracker b/PlayerTracker new file mode 100755 index 0000000..d85c4b9 Binary files /dev/null and b/PlayerTracker differ diff --git a/include/app.hpp b/include/app.hpp new file mode 100644 index 0000000..33629a3 --- /dev/null +++ b/include/app.hpp @@ -0,0 +1,19 @@ +#ifndef APP_CONFIG_HPP +#define APP_CONFIG_HPP + +#include +#include + +struct app_info { + // From args + uint16_t app_id; + uint16_t app_port_in; + uint16_t app_port_out; + + // From .env + std::string app_api_socket_path; + uint16_t max_players; + std::string app_server_out_ip; +}; + +#endif diff --git a/include/file.hpp b/include/file.hpp index 80b0a25..582f280 100644 --- a/include/file.hpp +++ b/include/file.hpp @@ -8,6 +8,7 @@ #include #include +#include "app.hpp" #include "server_structs.h" using namespace std; diff --git a/include/server_structs.h b/include/server_structs.h index 24fbe07..07e8b23 100644 --- a/include/server_structs.h +++ b/include/server_structs.h @@ -4,18 +4,6 @@ #include #include -typedef struct app_info { - // From args - u_int16_t app_id; - u_int16_t app_port_in; - u_int16_t app_port_out; - - // From .env - const char *app_api_socket_path; - u_int16_t max_players; - const char *app_server_out_ip; -} __attribute__((packed)) app_info; - typedef struct handshake { // [not used in the current Remote Telemtry version by AC] // In future versions it will identify the platform type of the client. diff --git a/source/file.cpp b/source/file.cpp index b6051a9..bb6e0c2 100644 --- a/source/file.cpp +++ b/source/file.cpp @@ -50,9 +50,9 @@ app_info parce_args(int argc, char *argv[]) { // std::cout << '[' << key << "] = " << value << "; "; // } - __processed_info.app_api_socket_path = __env_args["API_SOCKET_PATH"].c_str(); + __processed_info.app_api_socket_path = __env_args["API_SOCKET_PATH"]; __processed_info.max_players = (u_int16_t)atoi(__env_args["MAX_PLAYERS"].c_str()); - __processed_info.app_server_out_ip = __env_args["SERVER_OUT_IP"].c_str(); + __processed_info.app_server_out_ip = __env_args["SERVER_OUT_IP"]; return __processed_info; } diff --git a/source/main.cpp b/source/main.cpp index c30f68a..052c9f0 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -5,6 +5,7 @@ #include #include +#include "app.hpp" // for app_info struct #include "file.hpp" // for parce_args #include "net.hpp" // for socket operations #include "server_structs.h" @@ -18,7 +19,7 @@ int main(int argc, char *argv[]) { try { Socket sock; // Connect to API socket path - sock.connect_unix(app.app_api_socket_path, app.app_port_out); + sock.connect_unix(app.app_api_socket_path.c_str(), app.app_port_out); // Send a packet for test to API packet = sock.create_packet(app.app_id); // tracker_id = 1