⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipstack.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 2 页
字号:
{   //assert(!mShuttingDown);   SipMessage* toSend = new SipMessage(msg);   if (tu) toSend->setTransactionUser(tu);   toSend->setForceTarget(uri);   toSend->setFromTU();   mTransactionController.send(toSend);   checkAsyncProcessHandler();}// this is only if you want to send to a destination not in the route. You// probably don't want to use it. void SipStack::sendTo(const SipMessage& msg, const Tuple& destination, TransactionUser* tu){   assert(!mShuttingDown);      //SipMessage* toSend = new SipMessage(msg);   SipMessage* toSend = dynamic_cast<SipMessage*>(msg.clone());   if (tu) toSend->setTransactionUser(tu);   toSend->setDestination(destination);   toSend->setFromTU();   mTransactionController.send(toSend);   checkAsyncProcessHandler();}void SipStack::checkAsyncProcessHandler(){   if (mAsyncProcessHandler)   {      mAsyncProcessHandler->handleProcessNotification();   }}voidSipStack::post(const ApplicationMessage& message){   assert(!mShuttingDown);   Message* toPost = message.clone();   //mTUFifo.add(toPost, TimeLimitFifo<Message>::InternalElement);   mTuSelector.add(toPost, TimeLimitFifo<Message>::InternalElement);}voidSipStack::post(const ApplicationMessage& message,  unsigned int secondsLater,               TransactionUser* tu){   assert(!mShuttingDown);   postMS(message, secondsLater*1000, tu);}voidSipStack::postMS(const ApplicationMessage& message, unsigned int ms,                 TransactionUser* tu){   assert(!mShuttingDown);   Message* toPost = message.clone();   if (tu) toPost->setTransactionUser(tu);   Lock lock(mAppTimerMutex);   mAppTimers.add(Timer(ms, toPost));   //.dcm. timer update rather than process cycle...optimize by checking if sooner   //than current timeTillNextProcess?   checkAsyncProcessHandler();}void SipStack::post(std::auto_ptr<ApplicationMessage> message,                unsigned int secondsLater,               TransactionUser* tu){   postMS(message, secondsLater*1000, tu);}void SipStack::postMS( std::auto_ptr<ApplicationMessage> message,                   unsigned int ms,                  TransactionUser* tu){   assert(!mShuttingDown);   if (tu) message->setTransactionUser(tu);   Lock lock(mAppTimerMutex);   mAppTimers.add(Timer(ms, message.release()));   //.dcm. timer update rather than process cycle...optimize by checking if sooner   //than current timeTillNextProcess?   checkAsyncProcessHandler();}boolSipStack::hasMessage() const{   return mTUFifo.messageAvailable();}SipMessage* SipStack::receive(){   // Check to see if a message is available and if it is return the    // waiting message. Otherwise, return 0   if (mTUFifo.messageAvailable())   {      // we should only ever have SIP messages on the TU Fifo      // unless we've registered for termination messages.       Message* msg = mTUFifo.getNext();      SipMessage* sip = dynamic_cast<SipMessage*>(msg);      if (sip)      {         DebugLog (<< "RECV: " << sip->brief());         return sip;      }      else      {         // assert(0); // !CJ! removed the assert - happens 1 minute after         // stack starts up         delete msg;         return 0;      }   }   else   {      return 0;   }}Message*SipStack::receiveAny(){   // Check to see if a message is available and if it is return the    // waiting message. Otherwise, return 0   if (mTUFifo.messageAvailable())   {      // application messages can flow through      Message* msg = mTUFifo.getNext();      SipMessage* sip=dynamic_cast<SipMessage*>(msg);      if (sip)      {         DebugLog (<< "RECV: " << sip->brief());      }      return msg;   }   else   {      return 0;   }}void SipStack::process(FdSet& fdset){   if(!mShuttingDown && mStatisticsManagerEnabled)   {      mStatsManager.process();   }   mTransactionController.process(fdset);   mTuSelector.process();   mDnsStub->process(fdset);      Lock lock(mAppTimerMutex);    mAppTimers.process();}/// returns time in milliseconds when process next needs to be called unsigned int SipStack::getTimeTillNextProcessMS(){   Lock lock(mAppTimerMutex);   return resipMin(mTransactionController.getTimeTillNextProcessMS(),                   resipMin(mTuSelector.getTimeTillNextProcessMS(), mAppTimers.msTillNextTimer()));} void SipStack::buildFdSet(FdSet& fdset){   mTransactionController.buildFdSet(fdset);   mDnsStub->buildFdSet(fdset);}Security*SipStack::getSecurity() const {    return mSecurity;}voidSipStack::setStatisticsInterval(unsigned long seconds){   mStatsManager.setInterval(seconds);}void SipStack::registerTransactionUser(TransactionUser& tu){   mTuSelector.registerTransactionUser(tu);}void SipStack::requestTransactionUserShutdown(TransactionUser& tu){   mTuSelector.requestTransactionUserShutdown(tu);   checkAsyncProcessHandler();}void SipStack::unregisterTransactionUser(TransactionUser& tu){   mTuSelector.unregisterTransactionUser(tu);   checkAsyncProcessHandler();}voidSipStack::registerMarkListener(MarkListener* listener){   mTransactionController.registerMarkListener(listener);}voidSipStack::unregisterMarkListener(MarkListener* listener){   mTransactionController.unregisterMarkListener(listener);}DnsStub&SipStack::getDnsStub() const{   return *mDnsStub;}voidSipStack::setEnumSuffixes(const std::vector<Data>& suffixes){   mDnsStub->setEnumSuffixes(suffixes);}voidSipStack::clearDnsCache(){   mDnsStub->clearDnsCache();}voidSipStack::logDnsCache(){   mDnsStub->logDnsCache();}volatile bool& SipStack::statisticsManagerEnabled(){   return mStatisticsManagerEnabled;   }const bool SipStack::statisticsManagerEnabled() const{   return mStatisticsManagerEnabled;   }std::ostream& SipStack::dump(std::ostream& strm)  const{   Lock lock(mAppTimerMutex);   strm << "SipStack: " << (this->mSecurity ? "with security " : "without security ")        << std::endl        << "domains: " << Inserter(this->mDomains)        << std::endl        << " TUFifo size=" << this->mTUFifo.size() << std::endl        << " Timers size=" << this->mTransactionController.mTimers.size() << std::endl        << " AppTimers size=" << this->mAppTimers.size() << std::endl        << " ServerTransactionMap size=" << this->mTransactionController.mServerTransactionMap.size() << std::endl        << " ClientTransactionMap size=" << this->mTransactionController.mClientTransactionMap.size() << std::endl        << " Exact Transports=" << Inserter(this->mTransactionController.mTransportSelector.mExactTransports) << std::endl        << " Any Transports=" << Inserter(this->mTransactionController.mTransportSelector.mAnyInterfaceTransports) << std::endl;   return strm;}std::ostream& resip::operator<<(std::ostream& strm, const SipStack& stack) {   return stack.dump(strm);}boolSipStack::isFlowAlive(const resip::Tuple& flow) const{   return flow.getType()==UDP ||          mTransactionController.transportSelector().connectionAlive(flow);}/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -