sf::Packet& operator <<(sf::Packet& packet, const Client& A)
{
return packet << A;
}
sf::Packet& operator >>(sf::Packet& packet, Client& A)
{
return packet >> A;
}
The program breaks when it gets to this code and says stack overflow error. I think the problem is that i can only send primitive data types (int, string, bool, etc) through and not whole structures.
The obvious answer is to break down and reassemble the structure, but i am hesitant to do so because i am sending an array of these structs at a time. That code looks like
//send
packet << static_cast<sf::Uint32>(8);
for(int i = 0; i < 8; i++) // for each client
{
for( int j = 0; j < 8; i++)// for every client
{
packet << clientInfo[j];
socket.send(packet, clientInfo[i].address, port);
}
}
//receive
sf::Uint32 size;
packet >> size;
for( sf::Uint32 i= 0; i < size; ++i)
{
packet >> clientsInfo[i];
}
So should i break down and reassemble each struct(which would probably work), or is there another solution?
Edit: There must be another solution because what if the struct contains other structs? Am i expected to break down those as well?
This post has been edited by Nano511: 16 December 2012 - 04:16 PM

New Topic/Question
Reply



MultiQuote







|