本文整理汇总了C++中CBuffer::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::Print方法的具体用法?C++ CBuffer::Print怎么用?C++ CBuffer::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::Print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddHitDC
void CLocalSearch::AddHitDC(CDCPacket* pPacket, CSchemaMap& /*pSchemas*/, CLibraryFile* pFile, int /*nIndex*/)
{
// Active user:
// $SR Nick FileName<0x05>FileSize FreeSlots/TotalSlots<0x05>HubName (HubIP:HubPort)|
// Passive user:
// $SR Nick FileName<0x05>FileSize FreeSlots/TotalSlots<0x05>HubName (HubIP:HubPort)<0x05>User|
if ( ! m_pSearch )
return;
CUploadQueue* pQueue = UploadQueues.SelectQueue(
PROTOCOL_DC, NULL, 0, CUploadQueue::ulqBoth, NULL );
int nTotalSlots = pQueue ? pQueue->m_nMaxTransfers : 0;
int nActiveSlots = pQueue ? pQueue->GetActiveCount() : 0;
int nFreeSlots = nTotalSlots > nActiveSlots ? ( nTotalSlots - nActiveSlots ) : 0;
CString sHubName;
if ( pFile->m_oTiger )
// It's TTH search
sHubName = _T("TTH:") + pFile->m_oTiger.toString();
else
sHubName = m_pSearch->m_sMyHub;
CBuffer pAnswer;
pAnswer.Add( _P("$SR ") );
pAnswer.Print( m_pSearch->m_sMyNick );
pAnswer.Add( _P(" ") );
pAnswer.Print( pFile->m_sName );
pAnswer.Add( _P("\x05") );
CString strSize;
strSize.Format( _T("%I64u %d/%d"), pFile->m_nSize, nFreeSlots, nTotalSlots );
pAnswer.Print( strSize );
pAnswer.Add( _P("\x05") );
pAnswer.Print( sHubName );
pAnswer.Add( _P(" (") );
pAnswer.Print( HostToString( &m_pSearch->m_pMyHub ) );
pAnswer.Add( _P(")") );
if ( ! m_pSearch->m_bUDP )
{
pAnswer.Add( _P("\x05") );
pAnswer.Print( m_pSearch->m_sUserNick );
}
pAnswer.Add( _P("|") );
pPacket->Write( pAnswer.m_pBuffer, pAnswer.m_nLength );
}