fix: finnaly working!

This commit is contained in:
AfonsoCMSousa 2026-01-07 23:21:55 +00:00
parent 8e0b1ff50e
commit e5d09e9741

View File

@ -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;
}