本文整理汇总了C++中CChannel::GetChannelDataHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ CChannel::GetChannelDataHandler方法的具体用法?C++ CChannel::GetChannelDataHandler怎么用?C++ CChannel::GetChannelDataHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChannel
的用法示例。
在下文中一共展示了CChannel::GetChannelDataHandler方法的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;
}
示例2: ReceiveChannelData
void CXEPxibb::ReceiveChannelData(const CJid& rJid, u16 localCid, CBuffer* pBuffer)
{
CChannelDataHandler* pChannelDataHandler;
MutexOnChannelManager.Lock();
try
{
// we are looking for the channelmanager associate to the Jid
CChannelManager* pChannelManager = GetChannelManager(rJid);
if(pChannelManager == NULL)
throw CXEPxibbException(CXEPxibbException::XEPXEC_RECEIVECHANNELDATAERROR);
// we are looking for the channel associate to the localCid
CChannel* pChannel = pChannelManager->GetChannelByLocalCid(localCid);
if(pChannel == NULL)
throw CXEPxibbException(CXEPxibbException::XEPXEC_RECEIVECHANNELDATAERROR);
pChannelDataHandler = pChannel->GetChannelDataHandler();
}
catch(exception& e)
{
MutexOnChannelManager.UnLock();
#ifdef __DEBUG__
cerr << e.what() << endl;
#endif //__DEBUG__
throw CXEPxibbException(CXEPxibbException::XEPXEC_RECEIVECHANNELDATAERROR);
}
MutexOnChannelManager.UnLock();
CChannelDataStanza ChannelDataStanza;
if(!pXMPPCore->Receive(pChannelDataHandler, &ChannelDataStanza))
throw CXEPxibbException(CXEPxibbException::XEPXEC_RECEIVECHANNELDATAERROR);
CXMLNode* pData = ChannelDataStanza.GetChild("channel-data");
CBase64 Base64;
Base64.From64(pData->GetData(), pBuffer);
}
示例3: 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);
}
示例4: 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__
//.........这里部分代码省略.........
示例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);
}
示例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);
}
}
示例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;
}