* 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. */
| 635 | * @param family The family of STUN handlers to close. AF_UNSPEC to close all STUN handlers for this token. |
| 636 | */ |
| 637 | void 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. |
no test coverage detected