Destroy client, network sockets and other objects on shutdown.

This commit is contained in:
Mr_Goldberg
2022-08-10 03:24:29 -04:00
parent 04022c005f
commit 7163daa6c1
4 changed files with 109 additions and 29 deletions

View File

@ -751,7 +751,6 @@ Networking::Networking(CSteamID id, uint32 appid, uint16 port, std::set<IP_PORT>
{
tcp_port = udp_port = port;
own_ip = 0x7F000001;
alive = true;
last_run = std::chrono::high_resolution_clock::now();
this->appid = appid;
@ -843,6 +842,21 @@ Networking::Networking(CSteamID id, uint32 appid, uint16 port, std::set<IP_PORT>
reset_last_error();
}
Networking::~Networking()
{
for (auto &c : connections) {
kill_tcp_socket(c.tcp_socket_incoming);
kill_tcp_socket(c.tcp_socket_outgoing);
}
for (auto &c : accepted) {
kill_tcp_socket(c);
}
kill_socket(udp_socket);
kill_socket(tcp_socket);
}
Common_Message Networking::create_announce(bool request)
{
Announce *announce = new Announce();
@ -1265,13 +1279,3 @@ uint32 Networking::getOwnIP()
{
return own_ip;
}
void Networking::shutDown()
{
alive = false;
}
bool Networking::isAlive()
{
return alive;
}