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


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

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


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

示例1: SendStreamData

void CXEPxibb::SendStreamData(const CJid& rJid, u16 localCid, u16 localSid, CBuffer* pBuffer)
{
	u16 remoteCid;
	u16 remoteSid;
	MutexOnChannelManager.Lock();

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

		if(pChannel == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_SENDSTREAMDATAERROR);
				
		remoteCid = pChannel->GetRemoteCid();

		// we are looking for the stream associate to the localSid
		CStream* pStream = pChannel->GetStreamByLocalSid(localSid);

		if(pStream == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_SENDSTREAMDATAERROR);

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

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

	CStreamDataStanza StreamDataStanza(rJid, remoteCid, remoteSid);

	CXMLNode* pData = StreamDataStanza.GetChild("stream-data");
	
	string data;
	CBase64 Base64;
	
	Base64.To64(pBuffer, data);
	pData->SetData(data.c_str(), data.size());

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

示例2: CloseStream

void CXEPxibb::CloseStream(const CJid& rJid, u16 localCid, u16 localSid)
{
	u16 remoteCid;
	u16 remoteSid;
	
	MutexOnChannelManager.Lock();

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

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

		remoteCid = pChannel->GetRemoteCid();

		// we are looking for the stream associate to the localSid
		CStream* pStream = pChannel->GetStreamByLocalSid(localSid);

		if(pStream == NULL)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSESTREAMERROR);

		remoteSid = pStream->GetRemoteSid();

		pXMPPCore->CommitHandler(pStream->GetStreamDataHandler());
		pChannel->RemoveStreamByLocalSid(localSid);
	}
	
	catch(exception& e)
	{
		MutexOnChannelManager.UnLock();
		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSESTREAMERROR);
	}

	MutexOnChannelManager.UnLock();

	// we build the iq request
	string id;
	pXMPPCore->GenerateId(id);
	
	CStreamCloseStanza StreamCloseStanza(rJid, remoteCid, remoteSid, 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(&StreamCloseStanza))
	throw CXEPxibbException(CXEPxibbException::XEPXEC_CLOSESTREAMERROR);

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

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

示例3: OpenStream

void CXEPxibb::OpenStream(const CJid& rJid, u16 localCid, u16* pLocalSid, u16 blockSize, u32 byteRate)
{
	u16 localSid;
	
	MutexOnChannelManager.Lock();

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

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

		// we build and add the new stream
		CStream* pStream = new CStream();
		localSid = pChannel->AddStream(pStream);
		pStream->Init(rJid, pChannel->GetRemoteCid(), localSid, blockSize, byteRate);

		pXMPPCore->RequestHandler(pStream->GetStreamDataHandler());
		
		*pLocalSid = localSid;
	}

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

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

	// we build the stream:open iqstanza
	string id;
	CHandler IQHandler;
	CIQStanza IQStanza;

	CXMLFilter* pXMLFilter;
	CStreamOpenStanza StreamOpenStanza;
	pXMPPCore->GenerateId(id);

	try
	{
		StreamOpenStanza.Init(rJid, localCid, localSid, 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 stream:open iqstanza
		if(!pXMPPCore->Send(&StreamOpenStanza))
		throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENSTREAMERROR);

		// we receive the iq result
		if(!pXMPPCore->Receive(&IQHandler, &IQStanza))
		throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENSTREAMERROR);

		if(IQStanza.GetKindOf() != CIQStanza::SIQKO_RESULT)
		throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENSTREAMERROR);
	}
	
	catch(exception& e)
	{
		pXMPPCore->CommitHandler(&IQHandler);
		pXMPPCore->RemoveId(id);

		#ifdef __DEBUG__
		cerr << e.what() << endl;
		#endif //__DEBUG__

		throw CXEPxibbException(CXEPxibbException::XEPXEC_OPENCHANNELERROR);
	}
//.........这里部分代码省略.........
开发者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


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