本文整理汇总了C++中CChannel::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CChannel::Init方法的具体用法?C++ CChannel::Init怎么用?C++ CChannel::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChannel
的用法示例。
在下文中一共展示了CChannel::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EndChange
BOOL CChannels::EndChange(void)
{
int i;
SChannel* psAddedChannel;
SChannel* psRemovedChannel;
CChannel* psChannel;
int iSize;
int iOffset;
BOOL bAnyAdded;
int iOldBitStride;
int iAddedBitStride;
int iOldByteStride;
BOOL bResult;
//I don't think this handles the case where the channels have been re-ordered...
//Which as there *IS* no way of re-ordering them shouldn't be a problem.
bResult = TRUE;
if (IsChanging())
{
if (mpvUserData != mpsChangingDesc->pvUserData)
{
//Switch between using mabData and mpvUserData.
if ((mpvUserData == NULL) && (mpsChangingDesc->pvUserData != NULL))
{
FreeData();
}
else if ((mpvUserData != NULL) && (mpsChangingDesc->pvUserData == NULL))
{
AllocateData();
//should copy from mpvUserData
}
mpvUserData = (char*)mpsChangingDesc->pvUserData;
}
if (!IsUserAllocated())
{
//We're using mabData and have already allocated it.
if ((miBitStride != 0) && (miSize != 0))
{
//Remove
for (i = 0; i < mpsChangingDesc->asRemovedChannels.NumElements(); i++)
{
psRemovedChannel = mpsChangingDesc->asRemovedChannels.Get(i);
psChannel = GetChannel(psRemovedChannel->iChannel);
if (psChannel->Is8BitAligned())
{
iOffset = psChannel->miByteOffset;
iSize = psChannel->miByteSize;
mabData.BatchRemoveElements(iOffset, iSize, miSize, miByteStride);
}
else
{
//Deal with bitty removal.
}
masChannelOffsets.RemoveAt(masChannelOffsets.GetIndex(psChannel), TRUE);
Recalculate();
}
}
//Add
bAnyAdded = FALSE;
for (i = 0; i < mpsChangingDesc->asAddedChannels.NumElements(); i++)
{
psAddedChannel = mpsChangingDesc->asAddedChannels.Get(i);
psChannel = masChannelOffsets.Add();
psChannel->Init(psAddedChannel->iChannel, psAddedChannel->eType, psAddedChannel->bReverse);
bAnyAdded = TRUE;
}
if (bAnyAdded)
{
iOldBitStride = miBitStride;
iOldByteStride = miByteStride;
Recalculate();
iAddedBitStride = miBitStride - iOldBitStride;
if ((iAddedBitStride != 0) && (miSize != 0))
{
if (Is8BitAligned(iOldBitStride, iAddedBitStride))
{
iOffset = iOldByteStride;
iSize = iAddedBitStride / 8;
mabData.BatchInsertElements(iOffset, iSize, miSize, iOldByteStride);
}
else
{
//Deal with bitty addition.
}
}
}
//Change size due to size change.
if (mpsChangingDesc->iSize != miSize)
{
miSize = mpsChangingDesc->iSize;
iSize = CalculateByteSize(miBitStride, miSize);
mabData.GrowToNumElements(iSize);
}
}
//.........这里部分代码省略.........
示例2: OpenChannel
void CXEPxibb::OpenChannel(const CJid& rJid, u16* pLocalCid, u16 maxStream, u16 blockSize, u32 byteRate)
{
CChannelManager* pChannelManager;
CChannel* pChannel;
u16 localCid;
MutexOnChannelManager.Lock();
try
{
// we are looking for the channelmanager associate to the Jid
pChannelManager = GetChannelManager(rJid);
if(pChannelManager == NULL)
{
pChannelManager = new CChannelManager(rJid, maxChannel);
AddChannelManager(pChannelManager);
}
// we build the associate channel
pChannel = new CChannel();
// we add it
localCid = pChannelManager->AddChannel(pChannel);
pChannel->Init(rJid, localCid, maxStream, blockSize, byteRate);
pXMPPCore->RequestHandler(pChannel->GetChannelDataHandler());
pXMPPCore->RequestHandler(pChannel->GetStreamOpenHandler());
*pLocalCid = localCid;
}
catch(exception& e)
{
MutexOnChannelManager.UnLock();
#ifdef __DEBUG__
cerr << e.what() << endl;
#endif //__DEBUG__
throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENCHANNELERROR);
}
MutexOnChannelManager.UnLock();
// we build the channel:open iqstanza
string id;
CHandler IQHandler;
CXMLFilter* pXMLFilter;
CIQStanza IQStanza;
CChannelOpenStanza ChannelOpenStanza;
pXMPPCore->GenerateId(id);
try
{
ChannelOpenStanza.Init(rJid, localCid, maxStream, blockSize, byteRate, id);
// we build the handler associate to the iqstanza response
pXMLFilter = new CXMLFilter("iq");
pXMLFilter->SetAttribut("from", rJid.GetFull());
pXMLFilter->SetAttribut("id", id);
IQHandler.AddXMLFilter(pXMLFilter);
}
catch(exception& e)
{
pXMPPCore->RemoveId(id);
#ifdef __DEBUG__
cerr << e.what() << endl;
#endif //__DEBUG__
throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENCHANNELERROR);
}
pXMPPCore->RequestHandler(&IQHandler);
try
{
// we send the channel:open iqstanza
if(!pXMPPCore->Send(&ChannelOpenStanza))
throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENCHANNELERROR);
// we receive the iq result
if(!pXMPPCore->Receive(&IQHandler, &IQStanza))
throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENCHANNELERROR);
if(IQStanza.GetKindOf() != CIQStanza::SIQKO_RESULT)
throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENCHANNELERROR);
}
catch(exception& e)
{
pXMPPCore->CommitHandler(&IQHandler);
pXMPPCore->RemoveId(id);
#ifdef __DEBUG__
cerr << e.what() << endl;
#endif //__DEBUG__
//.........这里部分代码省略.........