Skip to content

Commit

Permalink
added logs and fixed port for server
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzyhau committed Aug 11, 2023
1 parent 4b5c770 commit 8b66c93
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Features/Tas/TasProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ static bool attemptToInitializeServer() {
return false;
}

THREAD_PRINT("TAS server initialized on port %d.\n", server_port);

return true;
}

Expand Down Expand Up @@ -518,6 +520,7 @@ static void processConnections(bool is_server) {
SOCKET cl = accept(g_listen_sock, nullptr, nullptr);
if (cl != INVALID_SOCKET) {
g_connections.push_back({ cl, {} });
THREAD_PRINT("A controller connected to TAS server. Number of controllers: %d\n", g_connections.size());
fullUpdate(g_connections[g_connections.size() - 1], true);
}
}
Expand All @@ -530,12 +533,16 @@ static void processConnections(bool is_server) {
if (!receiveFromConnection(cl)) {
g_connections.erase(g_connections.begin() + i);
--i;

if (is_server) {
THREAD_PRINT("A controller disconnected from TAS server. Number of controllers: %d\n", g_connections.size());
}
}
}
}

static void mainThread() {
THREAD_PRINT("Starting TAS protocol\n");
THREAD_PRINT("Starting TAS protocol connection\n");

#ifdef _WIN32
WSADATA wsa_data;
Expand Down Expand Up @@ -648,7 +655,7 @@ CON_COMMAND(sar_tas_protocol_connect,
g_conn_data_mutex.lock();

g_client_ip = args[1];
g_client_port = args.ArgC() >= 3 ? std::atoi(args[2]) : DEFAULT_TAS_SERVER_SOCKET;
g_client_port = args.ArgC() >= 3 ? std::atoi(args[2]) : DEFAULT_TAS_CLIENT_SOCKET;

g_conn_data_mutex.unlock();

Expand All @@ -663,7 +670,7 @@ CON_COMMAND(sar_tas_protocol_server,
return console->Print(sar_tas_protocol_server.ThisPtr()->m_pszHelpString);
}
g_conn_data_mutex.lock();
g_server_port = args.ArgC() >= 1 ? std::atoi(args[2]) : DEFAULT_TAS_SERVER_SOCKET;
g_server_port = args.ArgC() >= 2 ? std::atoi(args[1]) : DEFAULT_TAS_SERVER_SOCKET;
g_conn_data_mutex.unlock();

g_is_server.store(true);
Expand Down

0 comments on commit 8b66c93

Please sign in to comment.