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


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

本文整理汇总了C++中CChannel::GetStreamOpenHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ CChannel::GetStreamOpenHandler方法的具体用法?C++ CChannel::GetStreamOpenHandler怎么用?C++ CChannel::GetStreamOpenHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CChannel的用法示例。


在下文中一共展示了CChannel::GetStreamOpenHandler方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnPresenceJob

void* CXEPxibb::OnPresenceJob(void* pvThis) throw()
{
	CXEPxibb* pXEPxibb = (CXEPxibb*) pvThis;
	CPresenceHandler* pPresenceHandler = &(pXEPxibb->PresenceHandler);
	CXMPPCore* pXMPPCore = pXEPxibb->pXMPPCore;

	CPresenceStanza PresenceStanza;

	while(pXMPPCore->Receive(pPresenceHandler, &PresenceStanza))
	{
		pXEPxibb->MutexOnChannelManager.Lock();
		
		try
		{
			CChannelManager* pChannelManager = pXEPxibb->GetChannelManager(PresenceStanza.GetFrom());

			if(pChannelManager != NULL)
			{
				for(u16 i = 0 ; i < pChannelManager->GetMaxChannel() ; i++)
				{
					CChannel* pChannel = pChannelManager->GetChannelByLocalCid(i);
					
					if(pChannel != NULL)
					{
						pXMPPCore->CommitHandler(pChannel->GetStreamOpenHandler());
						pXMPPCore->CommitHandler(pChannel->GetChannelDataHandler());
					
						for(u16 j = 0 ; j < pChannel->GetMaxStream() ; j++)
						{
							CStream* pStream = pChannel->GetStreamByLocalSid(j);
							
							if(pStream != NULL)
							{
								pXMPPCore->CommitHandler(pStream->GetStreamDataHandler());
								pChannel->RemoveStreamByLocalSid(j);
							}
						}
						
						pChannelManager->RemoveChannelByLocalCid(i);
					}
				}

				pXEPxibb->RemoveChannelManager(PresenceStanza.GetFrom());
			}
		}
		
		catch(exception& e)
		{
			#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		}
		
		pXEPxibb->MutexOnChannelManager.UnLock();
	}
	
	return NULL;
}
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:59,代码来源:CXEPxibb.cpp

示例2: CloseChannel

void CXEPxibb::CloseChannel(const CJid& rJid, u16 localCid)
{
	CChannel* pChannel;
	u16 remoteCid;

	MutexOnChannelManager.Lock();

	try
	{
		// we are looking for the channelmanager associate to the Jid 
		
		CChannelManager* pChannelManager = GetChannelManager(rJid);
				
		if(pChannelManager == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSECHANNELERROR);
		
		// we are looking for the channel associate to the localCid
		pChannel = pChannelManager->GetChannelByLocalCid(localCid);

		if(pChannel == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSECHANNELERROR);

		pXMPPCore->CommitHandler(pChannel->GetStreamOpenHandler());
		pXMPPCore->CommitHandler(pChannel->GetChannelDataHandler());
		
		for(u16 i = 0 ; i < pChannel->GetMaxStream() ; i++)
		{
			CStream* pStream = pChannel->GetStreamByLocalSid(i);
				
			if(pStream != NULL)
			{
				pXMPPCore->CommitHandler(pStream->GetStreamDataHandler());
				pChannel->RemoveStreamByLocalSid(i);
			}
		}

		remoteCid = pChannel->GetRemoteCid();
		pChannelManager->RemoveChannelByLocalCid(localCid);
	}
	
	catch(exception& e)
	{
		MutexOnChannelManager.UnLock();
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		return;
	}

	MutexOnChannelManager.UnLock();

	// we build the iq request
	string id;
	pXMPPCore->GenerateId(id);
	
	try
	{

		CChannelCloseStanza ChannelCloseStanza(rJid, remoteCid, id);

		// we build the handler associate to the iq request
		CIQResultStanza IQResultStanza;
		CHandler IQResultHandler;

		CXMLFilter* pXMLFilter = new CXMLFilter("iq");
		pXMLFilter->SetAttribut("from", rJid.GetFull());
		pXMLFilter->SetAttribut("id", id);

		IQResultHandler.AddXMLFilter(pXMLFilter);
		
		pXMPPCore->RequestHandler(&IQResultHandler);

		// we send the iq request
		if(!pXMPPCore->Send(&ChannelCloseStanza))
		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSECHANNELERROR);

		// we receive the iq result
		if(!pXMPPCore->Receive(&IQResultHandler, &IQResultStanza))
		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSECHANNELERROR);

		pXMPPCore->CommitHandler(&IQResultHandler);
	}
	
	catch(exception& e)
	{
		pXMPPCore->RemoveId(id);
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSECHANNELERROR);
	}

	pXMPPCore->RemoveId(id);
}
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:96,代码来源:CXEPxibb.cpp

示例3: 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

示例4: WaitStream

void CXEPxibb::WaitStream(const CJid& rJid, u16 localCid, u16* pLocalSid, u16* pBlockSize, u32* pByteRate)
{
	CChannelManager* pChannelManager;
	CStreamOpenHandler* pStreamOpenHandler;
	CChannel* pChannel;
	CStream* pStream;
	
	MutexOnChannelManager.Lock();

	try
	{		
		// we are looking for the channelmanager associate to the Jid 
		pChannelManager = GetChannelManager(rJid);
		
		if(pChannelManager == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITSTREAMERROR);
		
		// we are looking for the channel associate to the localCid 
		pChannel = pChannelManager->GetChannelByLocalCid(localCid);

		if(pChannel == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITSTREAMERROR);

		pStreamOpenHandler = pChannel->GetStreamOpenHandler();
	}
	
	catch(exception& e)
	{
		MutexOnChannelManager.UnLock();
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITSTREAMERROR);
	}
	
	MutexOnChannelManager.UnLock();

	// we receive a stream open stanza
	CStreamOpenStanza StreamOpenStanza;
		
	if(!pXMPPCore->Receive(pStreamOpenHandler, &StreamOpenStanza))
	throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITSTREAMERROR);

	MutexOnChannelManager.Lock();

	try
	{
		*pBlockSize = StreamOpenStanza.GetBlockSize();
		*pByteRate = StreamOpenStanza.GetByteRate();

		pStream = new CStream(rJid, pChannel->GetRemoteCid(), StreamOpenStanza.GetStreamId(), *pBlockSize, *pByteRate);
		u16 localSid = pChannel->AddStream(pStream);

		pXMPPCore->RequestHandler(pStream->GetStreamDataHandler());

		*pLocalSid = localSid;
	}
	
	catch(exception& e)
	{
		MutexOnChannelManager.UnLock();
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITSTREAMERROR);
	}

	MutexOnChannelManager.UnLock();

	// we send the iq response
	CIQResultStanza IQResultStanza;

	IQResultStanza.SetTo(StreamOpenStanza.GetFrom());
	IQResultStanza.SetId(StreamOpenStanza.GetId());

	if(!pXMPPCore->Send(&IQResultStanza))
	throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITSTREAMERROR);		
}
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:80,代码来源:CXEPxibb.cpp

示例5: WaitChannel

void CXEPxibb::WaitChannel(CJid* pJid, u16* pLocalCid, u16* pMaxStream, u16* pBlockSize, u32* pByteRate)
{
	// we receive a channel open stanza
	CChannelOpenStanza ChannelOpenStanza;

	if(!pXMPPCore->Receive(&ChannelOpenHandler, &ChannelOpenStanza))
	throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITCHANNELERROR);

	// we are looking for if it already exists or building it otherwise
	MutexOnChannelManager.Lock();
		
	try
	{
		CChannelManager* pChannelManager = GetChannelManager(ChannelOpenStanza.GetFrom());
		
		*pMaxStream = ChannelOpenStanza.GetMaxStream();
		*pBlockSize = ChannelOpenStanza.GetBlockSize();
		*pByteRate = ChannelOpenStanza.GetByteRate();
		
		if(pChannelManager == NULL)
		{
			pChannelManager = new CChannelManager(ChannelOpenStanza.GetFrom(), maxChannel);
			AddChannelManager(pChannelManager);
		}
		
		// we build the associate channel
		CChannel* pChannel = new CChannel(ChannelOpenStanza.GetFrom(),
											ChannelOpenStanza.GetChannelId(),
											*pMaxStream,
											*pBlockSize,
											*pByteRate);

		// we add it
		u16 localCid = pChannelManager->AddChannel(pChannel);
	
		pXMPPCore->RequestHandler(pChannel->GetChannelDataHandler());
		pXMPPCore->RequestHandler(pChannel->GetStreamOpenHandler());

		*pJid = ChannelOpenStanza.GetFrom();
		*pLocalCid = localCid;
	}

	catch(exception& e)
	{
		MutexOnChannelManager.UnLock();
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITCHANNELERROR);
	}
	
	MutexOnChannelManager.UnLock();

	// we send the iq response
	CIQResultStanza IQResultStanza;

	IQResultStanza.SetTo(ChannelOpenStanza.GetFrom());
	IQResultStanza.SetId(ChannelOpenStanza.GetId());

	if(!pXMPPCore->Send(&IQResultStanza))
	throw CXEPxibbException(CXEPxibbException::XEPXEC_WAITCHANNELERROR);		
}
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:63,代码来源:CXEPxibb.cpp

示例6: Detach

void CXEPxibb::Detach()
{
	try
	{
		if(pXMPPCore == NULL)
		return;
	
		pXMPPCore->CommitHandler(&ChannelOpenHandler);
		pXMPPCore->CommitHandler(&ChannelCloseHandler);
		pXMPPCore->CommitHandler(&StreamCloseHandler);
		pXMPPCore->CommitHandler(&PresenceHandler);
	
		ThreadOnChannelCloseJob.Wait();
		ThreadOnStreamCloseJob.Wait();
		ThreadOnPresenceJob.Wait();
	
		for(u16 i = 0 ; i < ChannelManagerList.size() ; i++)
		{
			CChannelManager* pChannelManager = ChannelManagerList[i];
			
			if(pChannelManager != NULL)
			{
				for(u16 j = 0 ; j < pChannelManager->GetMaxChannel() ; j++)
				{
					CChannel* pChannel = pChannelManager->GetChannelByLocalCid(j);

					if(pChannel != NULL)
					{
						pXMPPCore->CommitHandler(pChannel->GetStreamOpenHandler());
						pXMPPCore->CommitHandler(pChannel->GetChannelDataHandler());
						
						for(u16 k = 0 ; k < pChannel->GetMaxStream() ; k++)
						{
							CStream* pStream = pChannel->GetStreamByLocalSid(k);
								
							if(pStream != NULL)
							{
								pXMPPCore->CommitHandler(pStream->GetStreamDataHandler());
								pChannel->RemoveStreamByLocalSid(k);
							}
						}

						pChannelManager->RemoveChannelByLocalCid(j);
					}	
				}
				
				delete pChannelManager;
				ChannelManagerList[i] = NULL;
			}
		}
	
		pXMPPCore = NULL;
	}
	
	catch(exception& e)
	{
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_DETACHERROR);
	}
}
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:63,代码来源:CXEPxibb.cpp

示例7: OnChannelCloseJob

void* CXEPxibb::OnChannelCloseJob(void* pvThis) throw()
{
	CXEPxibb* pXEPxibb = (CXEPxibb*) pvThis;
	CChannelCloseHandler* pChannelCloseHandler = &(pXEPxibb->ChannelCloseHandler);
	CXMPPCore* pXMPPCore = pXEPxibb->pXMPPCore;

	CChannelCloseStanza ChannelCloseStanza;

	while(pXMPPCore->Receive(pChannelCloseHandler, &ChannelCloseStanza))
	{
		pXEPxibb->MutexOnChannelManager.Lock();
		
		try
		{
			CChannelManager* pChannelManager = pXEPxibb->GetChannelManager(ChannelCloseStanza.GetRemoteJid());

			if(pChannelManager != NULL)
			{
				CChannel* pChannel = pChannelManager->GetChannelByRemoteCid(ChannelCloseStanza.GetChannelId());

				if(pChannel != NULL)
				{
					pXMPPCore->CommitHandler(pChannel->GetStreamOpenHandler());
					pXMPPCore->CommitHandler(pChannel->GetChannelDataHandler());
				
					for(u16 i = 0 ; i < pChannel->GetMaxStream() ; i++)
					{
						CStream* pStream = pChannel->GetStreamByLocalSid(i);
						
						if(pStream != NULL)
						{
							pXMPPCore->CommitHandler(pStream->GetStreamDataHandler());
							pChannel->RemoveStreamByLocalSid(i);
						}
					}
				}
				
				pChannelManager->RemoveChannelByRemoteCid(ChannelCloseStanza.GetChannelId());
			}
		}
		
		catch(exception& e)
		{
			#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		}
		
		pXEPxibb->MutexOnChannelManager.UnLock();

		CIQResultStanza IQResultStanza;		
		IQResultStanza.SetTo(ChannelCloseStanza.GetRemoteJid());
		IQResultStanza.SetId(ChannelCloseStanza.GetId());
		 
		if(!pXMPPCore->Send(&IQResultStanza))
		return NULL;
	}
	
	return NULL;
}
开发者ID:jahrome,项目名称:xmpp-tunnel,代码行数:61,代码来源:CXEPxibb.cpp


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