示例#1
0
void Server::in_ping_ACK(Packet* p)
{
	sf::Uint8 sortingId;
	*p >> sortingId;

	Package* pack = connection.getPacketNR(sortingId);
	if (pack == 0)
	{
		cout << "Recieved ACK on a non-used package slot?" << endl;
		return;
	}
	//ping doesnt use event ID so it should be empty
	if (pack->getEventID() != NET_EVENT_ID::EMPTY)
	{
		cout << "Recieved ACK on WRONG package slot?" << endl;
		return;
	}

	unsigned int oldStamp = pack->getTimeStamp();
	unsigned int temp = clock();
	oldStamp = temp - oldStamp;

	cout << "Ping Confirmed. RTT: " << oldStamp << endl;
	connection.successfulPing = true;

	connection.clearPacketNR(sortingId);
}