📄 dialogset.cxx
字号:
if( 0 != lastRequest.get() && !(lastRequest->header(h_CSeq) == msg.header(h_CSeq))) { InfoLog(<< "Cannot create a dialog, cseq does not match initial dialog request (illegal mid-dialog fork? see 3261 14.1)."); return; } } else { ErrLog(<< "Can抰 create a dialog, on a UAS response."); return; } int code = msg.header(h_StatusLine).statusCode(); if (code > 100 && code < 200 && (!msg.exists(h_Contacts) || !msg.exists(h_To) || !msg.header(h_To).exists(p_tag))) { InfoLog ( << "Cannot create a dialog, no Contact or To tag in 1xx." ); if (mDum.mDialogSetHandler) { mDum.mDialogSetHandler->onNonDialogCreatingProvisional(mAppDialogSet->getHandle(), msg); } return; } // If failure response and no dialogs, create a dialog, otherwise else if (code >= 300 && !mDialogs.empty()) { dispatchToAllDialogs(msg); return; } } DebugLog ( << "mState == " << mState << " Creating a new Dialog from msg: " << std::endl << std::endl <<msg); try { // !jf! This could throw due to bad header in msg, should we catch and rethrow dialog = new Dialog(mDum, msg, *this); } catch(BaseException& e) { InfoLog( << "Unable to create dialog: " << e.getMessage()); if (msg.isResponse()) { //don't delete on provisional responses, as FWD will eventually send a //valid 200 if(mDialogs.empty() && msg.header(h_StatusLine).statusCode() >= 200) { // really we should wait around 32s before deleting this mState = Destroying; mDum.destroy(this); } } else { // !jf! derek thinks we should destroy only on invalid CANCEL or // BYE, hmmphh. see draft-sparks-sipping-dialogusage-01.txt SharedPtr<SipMessage> response(new SipMessage); mDum.makeResponse(*response, msg, 400); mDum.send(response); if(mDialogs.empty()) { mState = Destroying; mDum.destroy(this); } } return; } assert(mState != WaitingToEnd); DebugLog ( << "### Calling CreateAppDialog ###: " << std::endl << std::endl <<msg); AppDialog* appDialog = mAppDialogSet->createAppDialog(msg); dialog->mAppDialog = appDialog; appDialog->mDialog = dialog; dialog->dispatch(msg); } else { dialog->dispatch(msg); }}ClientOutOfDialogReq*DialogSet::findMatchingClientOutOfDialogReq(const SipMessage& msg){ for (std::list<ClientOutOfDialogReq*>::iterator i=mClientOutOfDialogRequests.begin(); i != mClientOutOfDialogRequests.end(); ++i) { if ((*i)->matches(msg)) { return *i; } } return 0;}Dialog*DialogSet::findDialog(const DialogId id){ StackLog (<< "findDialog: " << id << " in " << Inserter(mDialogs)); DialogMap::iterator i = mDialogs.find(id); if (i == mDialogs.end()) { return 0; } else { if(i->second->isDestroying()) { return 0; } else { return i->second; } }}voidDialogSet::end(){ switch(mState) { case Initial: mState = WaitingToEnd; break; case WaitingToEnd: break; case ReceivedProvisional: { assert (mCreator->getLastRequest()->header(h_CSeq).method() == INVITE); mState = Terminating; // !jf! this should be made exception safe SharedPtr<SipMessage> cancel(Helper::makeCancel(*getCreator()->getLastRequest())); mDum.send(cancel); if (mDialogs.empty()) { // !jf! if 200/INV crosses a CANCEL that was sent after receiving // non-dialog creating provisional (e.g. 100), then we need to: // Add a new state, if we receive a 200/INV in this state, ACK and // then send a BYE and destroy the dialogset. mState = Destroying; mDum.destroy(this); } else { //need to lag and do last element ouside of look as this DialogSet will be //deleted if all dialogs are destroyed for (DialogMap::iterator it = mDialogs.begin(); it != mDialogs.end(); it++) { try { it->second->cancel(); } catch(UsageUseException& e) { InfoLog (<< "Caught: " << e); } } } } break; case Established: { for (DialogMap::iterator it = mDialogs.begin(); it != mDialogs.end(); ++it) { try { it->second->end(); } catch(UsageUseException& e) { InfoLog (<< "Caught: " << e); } } mState = Terminating; break; } case Terminating: case Destroying: DebugLog (<< "DialogSet::end() called on a DialogSet that is already Terminating"); //assert(0); }}ClientRegistrationHandleDialogSet::getClientRegistration(){ if (mClientRegistration) { return mClientRegistration->getHandle(); } else { return ClientRegistrationHandle::NotValid(); }}ServerRegistrationHandleDialogSet::getServerRegistration(){ if (mServerRegistration) { return mServerRegistration->getHandle(); } else { return ServerRegistrationHandle::NotValid(); }}ClientPublicationHandleDialogSet::getClientPublication(){ if (mClientPublication) { return mClientPublication->getHandle(); } else { return ClientPublicationHandle::NotValid(); }}ClientRegistration*DialogSet::makeClientRegistration(const SipMessage& response){ BaseCreator* creator = getCreator(); assert(creator); return new ClientRegistration(mDum, *this, creator->getLastRequest());}ClientPublication*DialogSet::makeClientPublication(const SipMessage& response){ BaseCreator* creator = getCreator(); assert(creator); return new ClientPublication(mDum, *this, creator->getLastRequest());}ClientOutOfDialogReq*DialogSet::makeClientOutOfDialogReq(const SipMessage& response){ BaseCreator* creator = getCreator(); assert(creator); return new ClientOutOfDialogReq(mDum, *this, *creator->getLastRequest());}ServerRegistration*DialogSet::makeServerRegistration(const SipMessage& request){ return new ServerRegistration(mDum, *this, request);}ServerOutOfDialogReq*DialogSet::makeServerOutOfDialog(const SipMessage& request){ return new ServerOutOfDialogReq(mDum, *this, request);}ServerPagerMessage*DialogSet::makeServerPagerMessage(const SipMessage& request){ return new ServerPagerMessage(mDum, *this, request);}ServerOutOfDialogReqHandleDialogSet::getServerOutOfDialog(){ if (mServerOutOfDialogRequest) { return mServerOutOfDialogRequest->getHandle(); } else { return ServerOutOfDialogReqHandle::NotValid(); }}void DialogSet::dispatchToAllDialogs(const SipMessage& msg){ if (!mDialogs.empty()) { for(DialogMap::iterator it = mDialogs.begin(); it != mDialogs.end(); it++) { it->second->dispatch(msg); } }}SharedPtr<UserProfile>DialogSet::getUserProfile(){ if(mUserProfile.get()) { return mUserProfile; } else { // If no UserProfile set then use UserProfile of the MasterProfile return mDum.getMasterUserProfile(); }}voidDialogSet::setUserProfile(SharedPtr<UserProfile> userProfile){ assert(userProfile.get()); mUserProfile = userProfile;}/* ==================================================================== * 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 written1 * 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 + -