Basically, i send two messages straight after each other, and the second is not received by the client at all, here is my code:
for (int i = 0; i < WC.clients.size(); i++)
{
if (WC.clients == nullptr || i == foundEmpty)
continue;
mapData.clear();
mapData << (sf::Int32)2 << (sf::Int32)0 << (sf::Int32)i;
WC.clients[foundEmpty]->send(mapData);
cout << "(2) Sending " << i << " to " << foundEmpty << endl;
}
foundempty is the ID of the client's socket in the array, this code is on the server and successfully prints:
(2) Sending 0 to 2
(2) Sending 1 to 2
On the client there is this code to receive the data:
sf::Packet recievedata;
if(WC.socket.receive(recievedata) == sf::Socket::Done)
{
sf::Int32 messageType;
recievedata >> messageType;
switch (messageType)
{
case 2://Other Player
sf::Int32 oPlayerMessage;
recievedata >> oPlayerMessage;
{
switch (oPlayerMessage)
{
case 0://create new player
{
sf::Int32 OPID;
recievedata >> OPID;
cout << "Player created: " << OPID << endl;
if(WC.otherPlayers[OPID] == nullptr)
WC.otherPlayers[OPID] = new otherPlayer(WC);
break;
}
}
}
}
}
This prints:
Player created: 0
The sockets are non-blocking, and this code runs on a loop.
If i decide to send the information later, it works, it just does not work as it is in this code, i could probably do a workaround by sending all the players in one packet, but i need to know why it's broken before continuing...
Sorry for the messy code, ill try to create a minimal code example later.
Also, these packets successfully get received on my computer at home, but on this computer it does not.
Only one packet gets received.