diff --git a/source/main.cpp b/source/main.cpp index 052c9f0..5792c79 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -14,23 +14,32 @@ using namespace std; int main(int argc, char *argv[]) { app_info app = parce_args(argc, argv); - api_packet packet; + api_packet packet; - try { - Socket sock; - // Connect to API socket path - sock.connect_unix(app.app_api_socket_path.c_str(), app.app_port_out); + Socket sock; - // Send a packet for test to API - packet = sock.create_packet(app.app_id); // tracker_id = 1 - sock.send_unix(packet); + try { + // Connect to API socket path + sock.connect_unix(app.app_api_socket_path.c_str(), app.app_port_out); - } catch (const runtime_error &e) { - cerr << "Error: " << e.what() << endl; - return 1; - } + // Send a packet for test to API + packet = sock.create_packet(app.app_id); + sock.send_unix(packet); + } catch (const runtime_error &e) { + cerr << "Error: " << e.what() << endl; + return 1; + } + + api_packet test; + + test.tracker_id = app.app_id; + test.connected_players = 0; + strncpy(test.track_info.server_name, "THIS IS A TEST, IF YOU CAN READ THIS, IT WORKS!", sizeof(test.track_info.server_name) - 1); + + cout << "Test packet server name: " << test.track_info.server_name << endl; + sock.set_packet(test); + sock.send_unix(); return 0; } - diff --git a/source/net.cpp b/source/net.cpp index 2aef392..ed64a56 100644 --- a/source/net.cpp +++ b/source/net.cpp @@ -25,7 +25,6 @@ void Socket::connect_server(const char *ip, uint16_t port) { void Socket::connect_unix(const char *ip, uint16_t port) { sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - perror("socket() Failed"); throw std::runtime_error("Failed to create UNIX socket"); } @@ -37,8 +36,6 @@ void Socket::connect_unix(const char *ip, uint16_t port) { if (connect(sock, (struct sockaddr *)&server_addr_unix, sizeof(server_addr_unix)) < 0) { throw std::runtime_error("Failed to connect to UNIX socket"); } - - printf("Connected to UNIX socket at %s\n", ip); } void Socket::send_server() {