|
reSIProcate/DialogUsageManager
9680
|
00001 #include "resip/stack/SipMessage.hxx" 00002 #include "resip/stack/MethodTypes.hxx" 00003 #include "resip/dum/ClientOutOfDialogReq.hxx" 00004 #include "resip/dum/OutOfDialogHandler.hxx" 00005 #include "resip/dum/DialogUsageManager.hxx" 00006 #include "resip/dum/Dialog.hxx" 00007 #include "rutil/Logger.hxx" 00008 00009 using namespace resip; 00010 00011 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM 00012 00013 ClientOutOfDialogReqHandle 00014 ClientOutOfDialogReq::getHandle() 00015 { 00016 return ClientOutOfDialogReqHandle(mDum, getBaseHandle().getId()); 00017 } 00018 00019 ClientOutOfDialogReq::ClientOutOfDialogReq(DialogUsageManager& dum, 00020 DialogSet& dialogSet, 00021 const SipMessage& req) 00022 : NonDialogUsage(dum, dialogSet), 00023 mRequest(req) 00024 { 00025 } 00026 00027 ClientOutOfDialogReq::~ClientOutOfDialogReq() 00028 { 00029 mDialogSet.mClientOutOfDialogRequests.remove(this); 00030 } 00031 00032 void 00033 ClientOutOfDialogReq::end() 00034 { 00035 delete this; 00036 } 00037 00038 void 00039 ClientOutOfDialogReq::dispatch(const SipMessage& msg) 00040 { 00041 assert(msg.isResponse()); 00042 00043 if (msg.header(h_StatusLine).statusCode() >= 200) 00044 { 00045 OutOfDialogHandler *handler = mDum.getOutOfDialogHandler(msg.header(h_CSeq).method()); 00046 if(handler != NULL) 00047 { 00048 00049 if(msg.header(h_StatusLine).statusCode() >= 200 && msg.header(h_StatusLine).statusCode() < 300) 00050 { 00051 // Pass Response to Handler 00052 DebugLog ( << "ClientOutOfDialogReq::dispatch - handler found for " 00053 << getMethodName(msg.header(h_CSeq).method()) 00054 << " method success response."); 00055 handler->onSuccess(getHandle(), msg); 00056 } 00057 else 00058 { 00059 // Pass Response to Handler 00060 DebugLog ( << "ClientOutOfDialogReq::dispatch - handler found for " 00061 << getMethodName(msg.header(h_CSeq).method()) 00062 << " method failure response."); 00063 handler->onFailure(getHandle(), msg); 00064 } 00065 } 00066 else 00067 { 00068 DebugLog ( << "ClientOutOfDialogReq::dispatch - handler not found for " 00069 << getMethodName(msg.header(h_CSeq).method()) 00070 << " method response."); 00071 } 00072 00073 delete this; 00074 } 00075 else 00076 { 00077 // Wait for final response 00078 DebugLog ( << "ClientOutOfDialogReq::dispatch - encountered provisional response" << msg.brief() ); 00079 } 00080 } 00081 00082 const SipMessage& 00083 ClientOutOfDialogReq::getRequest() const 00084 { 00085 return mRequest; 00086 } 00087 00088 void 00089 ClientOutOfDialogReq::dispatch(const DumTimeout& timer) 00090 { 00091 } 00092 00093 bool 00094 ClientOutOfDialogReq::matches(const SipMessage& msg) const 00095 { 00096 return (DialogSetId(mRequest) == DialogSetId(msg)); 00097 } 00098 00099 EncodeStream& 00100 ClientOutOfDialogReq::dump(EncodeStream& strm) const 00101 { 00102 strm << "ClientOutOfDialogReq " << getMethodName(mRequest.header(h_RequestLine).method()) 00103 << " cseq=" << mRequest.header(h_CSeq).sequence(); 00104 return strm; 00105 } 00106 00107 00108 00109 00110 /* ==================================================================== 00111 * The Vovida Software License, Version 1.0 00112 * 00113 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00114 * 00115 * Redistribution and use in source and binary forms, with or without 00116 * modification, are permitted provided that the following conditions 00117 * are met: 00118 * 00119 * 1. Redistributions of source code must retain the above copyright 00120 * notice, this list of conditions and the following disclaimer. 00121 * 00122 * 2. Redistributions in binary form must reproduce the above copyright 00123 * notice, this list of conditions and the following disclaimer in 00124 * the documentation and/or other materials provided with the 00125 00126 * distribution. 00127 * 00128 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00129 * and "Vovida Open Communication Application Library (VOCAL)" must 00130 * not be used to endorse or promote products derived from this 00131 * software without prior written permission. For written 00132 * permission, please contact vocal@vovida.org. 00133 * 00134 * 4. Products derived from this software may not be called "VOCAL", nor 00135 * may "VOCAL" appear in their name, without prior written 00136 * permission of Vovida Networks, Inc. 00137 * 00138 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00139 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00140 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00141 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00142 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00143 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00144 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00145 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00146 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00147 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00148 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00149 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00150 * DAMAGE. 00151 * 00152 * ==================================================================== 00153 * 00154 * This software consists of voluntary contributions made by Vovida 00155 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00156 * Inc. For more information on Vovida Networks, Inc., please see 00157 * <http://www.vovida.org/>. 00158 * 00159 */
1.7.5.1