From e5d09e9741e64fbc6f539d7d43df19fcb5f309a5 Mon Sep 17 00:00:00 2001 From: AfonsoCMSousa Date: Wed, 7 Jan 2026 23:21:55 +0000 Subject: [PATCH] fix: finnaly working! --- source/main.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 82a3a6d..d497ce2 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -18,6 +18,7 @@ int main(int argc, char *argv[]) { Socket sock; + char buffer[2048]; try { // Connect socket to API @@ -26,7 +27,15 @@ int main(int argc, char *argv[]) { sock.connect_server(app.app_server_out_ip.c_str(), app.app_port_out); sock.bind_server("127.0.0.1", app.app_port_in); - // Right after connecting, send update rate request + // Await server for initial data + sock.receive_server(buffer, sizeof(buffer)); + cout << "[+] Received data from server!" << endl; + + if (buffer[0] == ACSP_VERSION) { + cout << "[+] Server API Version: " << (int)buffer[1] << endl; + } + + // Right after confirmation, send update rate request char request[516] = {0}; request[0] = ACSP_REALTIMEPOS_INTERVAL; request[1] = 120; @@ -46,17 +55,6 @@ int main(int argc, char *argv[]) { // TODO: Implement Cache // TAG: Because sometimes the parser doesnt have the name of the server because it started after the server init // we can cache it and reuse it to avoid NULL names in the DB - char buffer[2048]; - - sock.receive_server(buffer, sizeof(buffer)); - - cout << "[+] Received data from server!" << endl; - cout << "[+] Data (first 64 bytes): " << endl; - // printf buffer in hex - for (size_t i = 0; i < 64; i++) { - printf("%02X ", (unsigned char)buffer[i]); - } - printf("\n"); return 0; }