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

Method CloseStunHandler

src/network/network_coordinator.cpp:637–658  ·  view source on GitHub ↗

* Close the STUN handler. * @param token The token used for the STUN handlers. * @param family The family of STUN handlers to close. AF_UNSPEC to close all STUN handlers for this token. */

Source from the content-addressed store, hash-verified

635 * @param family The family of STUN handlers to close. AF_UNSPEC to close all STUN handlers for this token.
636 */
637void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(std::string_view token, uint8_t family)
638{
639 auto stun_it = this->stun_handlers.find(token);
640 if (stun_it == this->stun_handlers.end()) return;
641
642 if (family == AF_UNSPEC) {
643 for (auto &[family, stun_handler] : stun_it->second) {
644 stun_handler->CloseConnection();
645 stun_handler->CloseSocket();
646 }
647
648 this->stun_handlers.erase(stun_it);
649 } else {
650 auto family_it = stun_it->second.find(family);
651 if (family_it == stun_it->second.end()) return;
652
653 family_it->second->CloseConnection();
654 family_it->second->CloseSocket();
655
656 stun_it->second.erase(family_it);
657 }
658}
659
660/**
661 * Close the TURN handler.

Callers 3

CloseTokenMethod · 0.95
CloseAllConnectionsMethod · 0.95
OnFailureMethod · 0.80

Calls 5

findMethod · 0.45
endMethod · 0.45
CloseConnectionMethod · 0.45
CloseSocketMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected