MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CloseAllConnections

Method CloseAllConnections

src/network/network_coordinator.cpp:700–726  ·  view source on GitHub ↗

* Close all pending connection tokens. */

Source from the content-addressed store, hash-verified

698 * Close all pending connection tokens.
699 */
700void ClientNetworkCoordinatorSocketHandler::CloseAllConnections()
701{
702 /* Ensure all other pending connection attempts are also killed. */
703 if (this->game_connecter != nullptr) {
704 this->game_connecter->Kill();
705 this->game_connecter = nullptr;
706 }
707
708 /* Mark any pending connecters as failed. */
709 for (auto &[token, it] : this->connecter) {
710 this->CloseStunHandler(token);
711 this->CloseTurnHandler(token);
712 it.second->SetFailure();
713
714 /* Inform the Game Coordinator he can stop trying to connect us to the server. */
715 this->ConnectFailure(token, 0);
716 }
717 this->stun_handlers.clear();
718 this->turn_handlers.clear();
719 this->connecter.clear();
720
721 /* Also close any pending invite-code requests. */
722 for (auto &[invite_code, it] : this->connecter_pre) {
723 it->SetFailure();
724 }
725 this->connecter_pre.clear();
726}
727
728/**
729 * Check whether we received/can send some data from/to the Game Coordinator server and

Callers 2

CloseConnectionMethod · 0.95
NetworkCloseFunction · 0.80

Calls 6

CloseStunHandlerMethod · 0.95
CloseTurnHandlerMethod · 0.95
ConnectFailureMethod · 0.95
SetFailureMethod · 0.80
KillMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected