bool LoopbackDeviceLink::sendPacket(NetworkPacket &input)
{
NetworkPacket output((QString()));
NetworkPacket::unserialize(input.serialize(), &output);
// LoopbackDeviceLink does not need deviceTransferInfo
if (input.hasPayload()) {
bool b = input.payload()->open(QIODevice::ReadOnly);
Q_ASSERT(b);
output.setPayload(input.payload(), input.payloadSize());
}
Q_EMIT receivedPacket(output);
return true;
}
This sends a network packet to the loopback device link. It creates a new network packet from the input object, and unserializes the packet, and sets the payload on the output object. It returns true on the first successful attempt. If the payload is not possible, the function creates a read - only stream and opens it using the read-only mode.