bool TestDevice::sendPacket(NetworkPacket &np)
{
++sentPackets;
// copy packet manually to allow for inspection (can't use copy-constructor)
deleteLastPacket();
lastPacket = new NetworkPacket(np.type());
Q_ASSERT(lastPacket);
for (QVariantMap::ConstIterator iter = np.body().constBegin(); iter != np.body().constEnd(); iter++)
lastPacket->set(iter.key(), iter.value());
lastPacket->setPayload(np.payload(), np.payloadSize());
return true;
}
This sends a network packet, and returns true on the first successful send. It creates a new last packet, sets all entries of the given network packet to its internal state and sets the payload of the last packet to the payload size.