当前位置: 首页>>代码示例>>C++>>正文


C++ CChannel::Init方法代码示例

本文整理汇总了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);
			}
		}
//.........这里部分代码省略.........
开发者ID:chrisjaquet,项目名称:Codaphela.Library,代码行数:101,代码来源:Channels.cpp

示例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__

//.........这里部分代码省略.........
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:101,代码来源:CXEPxibb.cpp


注:本文中的CChannel::Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。