Logo Search packages:      
Sourcecode: kmess version File versions

void P2PApplicationBase::sendP2PMessage ( const QByteArray &  messageData,
int  flagField = 0,
P2PDataType  footerCode = P2P_TYPE_NEGOTIATION,
P2PMessageType  messageType = P2P_MSG_UNKNOWN 
) [protected, inherited]

Sends a complete P2P message payload.

It splits the data message into chunks which fit in the individual P2P messages.

If you need to send data, use sendData() instead. This method is stream based, and also takes care of state changes.

Parameters:
messageData The message payload to send.
flagField The value for the flag field in the P2P header.
footerCode The message footer, which is appended when the message is sent over the switchboard.
messageType The type of the message. This value is returned with gotAck().

Definition at line 1740 of file p2papplicationbase.cpp.

References P2PApplicationBase::sendP2PMessageImpl().

Referenced by P2PApplicationBase::sendSlpMessage().

{
  // Make sure the message gets sent in chunks of 1202 bytes.
  // Only set fragmentTotalSize_ if there are chunks, for useless debug messages.
  int remainingBytes = messageData.size();
  fragmentOffset_    = 0;
  fragmentTotalSize_ = ( remainingBytes <= 1202 ? 0 : remainingBytes );

  do
  {
    // Let another QByteArray encapsulate a part of the utf8Message
    const char *dataPointer = messageData.data() + fragmentOffset_;
    uint        dataSize    = qMin( remainingBytes, 1202 );
    QByteArray  messagePart = QByteArray::fromRawData( dataPointer, dataSize );

    // Send the message with the generic sendP2PMessageImpl() method
    // fragmentOffset_ is updated automatically
    sendP2PMessageImpl( messagePart, flagField, footerCode, messageType );
    remainingBytes -= dataSize;

#ifdef KMESSTEST
    KMESS_ASSERT( (uint) remainingBytes == fragmentTotalSize_ - fragmentOffset_ );
#endif
  }
  while( remainingBytes > 0 );

  // Reset for normal operations
  fragmentOffset_    = 0;
  fragmentTotalSize_ = 0;
}


Generated by  Doxygen 1.6.0   Back to index