Codechange: use std::unique_ptr for the Packets created to send via TCP

This commit is contained in:
Rubidium
2024-02-03 19:55:51 +01:00
committed by rubidium42
parent 36e1b32ccf
commit 031a9d4e26
10 changed files with 164 additions and 169 deletions

View File

@@ -65,12 +65,12 @@ NetworkRecvStatus NetworkTCPSocketHandler::CloseConnection([[maybe_unused]] bool
* if the OS-network-buffer is full)
* @param packet the packet to send
*/
void NetworkTCPSocketHandler::SendPacket(Packet *packet)
void NetworkTCPSocketHandler::SendPacket(std::unique_ptr<Packet> &&packet)
{
assert(packet != nullptr);
packet->PrepareToSend();
this->packet_queue.push_back(std::unique_ptr<Packet>(packet));
this->packet_queue.push_back(std::move(packet));
}
/**

View File

@@ -47,7 +47,7 @@ public:
virtual NetworkRecvStatus CloseConnection(bool error = true);
void CloseSocket();
virtual void SendPacket(Packet *packet);
virtual void SendPacket(std::unique_ptr<Packet> &&packet);
SendPacketsState SendPackets(bool closing_down = false);
virtual std::unique_ptr<Packet> ReceivePacket();