MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / Quit

Function Quit

samples/application/chat/main.cpp:390–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390void Quit(int rc)
391{
392 if (rc == 0)
393 {
394 // OK, we cannot just exit the process, because we need to give
395 // the connection time to actually send the last message and clean up.
396 // If this were a TCP connection, we could just bail, because the OS
397 // would handle it. But this is an application protocol over UDP.
398 // So give a little bit of time for good cleanup. (Also note that
399 // we really ought to continue pumping the signaling service, but
400 // in this exampple we'll assume that no more signals need to be
401 // exchanged, since we've gotten this far.) If we just terminated
402 // the program here, our peer could very likely timeout. (Although
403 // it's possible that the cleanup packets have already been placed
404 // on the wire, and if they don't drop, things will get cleaned up
405 // properly.)
406 SKR_LOG_INFO(u8"Waiting for any last cleanup packets.\n");
407 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
408 }
409
410 GameNetworkingSockets_Kill();
411 exit(rc);
412}
413
414#ifdef _MSC_VER
415 #pragma warning(disable : 4702) /* unreachable code */

Callers 1

shutdownFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected