* Close current connections. * @param close_admins Whether the admin connections have to be closed as well. */
| 591 | * @param close_admins Whether the admin connections have to be closed as well. |
| 592 | */ |
| 593 | void NetworkClose(bool close_admins) |
| 594 | { |
| 595 | if (_network_server) { |
| 596 | if (close_admins) { |
| 597 | for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) { |
| 598 | as->CloseConnection(true); |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) { |
| 603 | cs->CloseConnection(NETWORK_RECV_STATUS_CLIENT_QUIT); |
| 604 | } |
| 605 | ServerNetworkGameSocketHandler::CloseListeners(); |
| 606 | ServerNetworkAdminSocketHandler::CloseListeners(); |
| 607 | |
| 608 | _network_coordinator_client.CloseConnection(); |
| 609 | } else { |
| 610 | if (MyClient::my_client != nullptr) { |
| 611 | MyClient::SendQuit(); |
| 612 | MyClient::my_client->CloseConnection(NETWORK_RECV_STATUS_CLIENT_QUIT); |
| 613 | } |
| 614 | |
| 615 | _network_coordinator_client.CloseAllConnections(); |
| 616 | } |
| 617 | NetworkGameSocketHandler::ProcessDeferredDeletions(); |
| 618 | |
| 619 | TCPConnecter::KillAll(); |
| 620 | |
| 621 | _networking = false; |
| 622 | _network_server = false; |
| 623 | |
| 624 | NetworkFreeLocalCommandQueue(); |
| 625 | |
| 626 | InitializeNetworkPools(close_admins); |
| 627 | } |
| 628 | |
| 629 | /* Initializes the network (cleans sockets and stuff) */ |
| 630 | static void NetworkInitialize(bool close_admins = true) |
no test coverage detected