Is there any way to shift a sf::Packet into anoter sf::Packet as seen below(figure1)? I am trying to setup a function that takes a sf::Packet as an arguement, stamps a name on the packet, and then sends it to a client. The problem now is that all that data in the data variable(figure 2) is lost when the data variable is shifted into the newPacket variable.
sf::Packet data;
std::string name = "Bob";
int age;
data << bob <<age;
sf::Packet FinalPacket;
std::string PacketType = "Name";
FinalPacket << PacketType << data;
figure 2
bool SFMLNetwork::sendUDP(sf::Packet data, std::string Type, sf::IpAddress receiver, unsigned short rcvPort)
{
sf::Packet newPacket;
// not sure if data can be shifted into newPacket
newPacket << Type << data;
if (UdpSocket.send(newPacket, receiver, rcvPort) == sf::Socket::Status::Done) {
return true;
}
else {
return false;
}
}