本文整理汇总了C++中CChannel::AddStream方法的典型用法代码示例。如果您正苦于以下问题:C++ CChannel::AddStream方法的具体用法?C++ CChannel::AddStream怎么用?C++ CChannel::AddStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChannel
的用法示例。
在下文中一共展示了CChannel::AddStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
//.........这里部分代码省略.........
示例2: 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);
}