From c6091b575664d9792e78557ad54771a84aa78543 Mon Sep 17 00:00:00 2001 From: BIAGINI Nathan Date: Sun, 24 Sep 2023 00:06:15 +0200 Subject: [PATCH] fix soak --- soak/client.c | 24 ++++++++++++------------ soak/server.c | 14 +++++++------- soak/soak.c | 8 -------- soak/soak_cli_out | 1 + soak/soak_serv_out | 1 + 5 files changed, 21 insertions(+), 27 deletions(-) create mode 100644 soak/soak_cli_out create mode 100644 soak/soak_serv_out diff --git a/soak/client.c b/soak/client.c index 735a0a3..fed2e6b 100644 --- a/soak/client.c +++ b/soak/client.c @@ -276,11 +276,22 @@ int main(int argc, char *argv[]) NBN_UDP_Register(); // Register the UDP driver #endif // __EMSCRIPTEN__ + if (NBN_GameClient_Start(SOAK_PROTOCOL_NAME, "127.0.0.1", SOAK_PORT) < 0) + { + Soak_LogError("Failed to start game client. Exit"); + +#ifdef __EMSCRIPTEN__ + emscripten_force_exit(1); +#else + return 1; +#endif + } + if (Soak_Init(argc, argv) < 0) { Soak_LogError("Failed to initialize soak test"); return 1; - } + } SoakOptions options = Soak_GetOptions(); unsigned int channel_count = options.channel_count; @@ -289,17 +300,6 @@ int main(int argc, char *argv[]) unsigned int leftover_message_count = message_count % channel_count; SoakChannel *channels = (SoakChannel *)malloc(sizeof(SoakChannel) * channel_count); - if (NBN_GameClient_Start(SOAK_PROTOCOL_NAME, "127.0.0.1", SOAK_PORT) < 0) - { - Soak_LogError("Failed to start game client. Exit"); - -#ifdef __EMSCRIPTEN__ - emscripten_force_exit(1); -#else - return 1; -#endif - } - for (int c = 0; c < channel_count; c++) { SoakChannel *channel = &channels[c]; diff --git a/soak/server.c b/soak/server.c index 8aaf9ed..c18c5fd 100644 --- a/soak/server.c +++ b/soak/server.c @@ -346,24 +346,24 @@ int main(int argc, char *argv[]) NBN_WebRTC_C_Register(); // Register native WebRTC driver #endif -#endif // __EMSCRIPTEN__ +#endif // __EMSCRIPTEN__ - if (Soak_Init(argc, argv) < 0) + if (NBN_GameServer_Start(SOAK_PROTOCOL_NAME, SOAK_PORT)) { - Soak_LogError("Failed to initialize soak test"); + Soak_LogError("Failed to start game server"); return 1; } - NBN_GameServer_Debug_RegisterCallback(NBN_DEBUG_CB_MSG_ADDED_TO_RECV_QUEUE, (void *)Soak_Debug_PrintAddedToRecvQueue); - - if (NBN_GameServer_Start(SOAK_PROTOCOL_NAME, SOAK_PORT)) + if (Soak_Init(argc, argv) < 0) { - Soak_LogError("Failed to start game server"); + Soak_LogError("Failed to initialize soak test"); return 1; } + NBN_GameServer_Debug_RegisterCallback(NBN_DEBUG_CB_MSG_ADDED_TO_RECV_QUEUE, (void *)Soak_Debug_PrintAddedToRecvQueue); + int ret = Soak_MainLoop(Tick, NULL); NBN_GameServer_Stop(); diff --git a/soak/soak.c b/soak/soak.c index 3f2e967..eccc1cb 100644 --- a/soak/soak.c +++ b/soak/soak.c @@ -74,10 +74,6 @@ int Soak_Init(int argc, char *argv[]) NBN_GameClient_RegisterReliableChannel(i); } -#ifdef SOAK_ENCRYPTION - NBN_GameClient_EnableEncryption(); -#endif - NBN_GameClient_RegisterMessage(SOAK_MESSAGE, (NBN_MessageBuilder)SoakMessage_CreateIncoming, (NBN_MessageDestructor)SoakMessage_Destroy, @@ -92,10 +88,6 @@ int Soak_Init(int argc, char *argv[]) NBN_GameServer_RegisterReliableChannel(i); } -#ifdef SOAK_ENCRYPTION - NBN_GameServer_EnableEncryption(); -#endif - NBN_GameServer_RegisterMessage(SOAK_MESSAGE, (NBN_MessageBuilder)SoakMessage_CreateIncoming, (NBN_MessageDestructor)SoakMessage_Destroy, diff --git a/soak/soak_cli_out b/soak/soak_cli_out new file mode 100644 index 0000000..2e2fc8d --- /dev/null +++ b/soak/soak_cli_out @@ -0,0 +1 @@ +./bin/github-actions/run_soak.sh: line 38: ./client: No such file or directory diff --git a/soak/soak_serv_out b/soak/soak_serv_out new file mode 100644 index 0000000..64a43ed --- /dev/null +++ b/soak/soak_serv_out @@ -0,0 +1 @@ +./bin/github-actions/run_soak.sh: line 18: ./server: No such file or directory