/[resiprocate]/main/sip/resiprocate/dum/ServerInviteSession.cxx
ViewVC logotype

Contents of /main/sip/resiprocate/dum/ServerInviteSession.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2997 - (show annotations) (download)
Wed Jun 16 01:08:25 2004 UTC (15 years, 7 months ago) by derek
File size: 6340 byte(s)
Basic call works w/out crash on exit now.  Added BYE logic to Dialog.
Dialog still needs work.
1 #include "resiprocate/SdpContents.hxx"
2 #include "resiprocate/dum/ClientInviteSession.hxx"
3 #include "resiprocate/dum/Dialog.hxx"
4 #include "resiprocate/dum/DialogUsageManager.hxx"
5 #include "resiprocate/dum/DumTimeout.hxx"
6 #include "resiprocate/dum/InviteSessionHandler.hxx"
7 #include "resiprocate/dum/ServerInviteSession.hxx"
8 #include "resiprocate/dum/UsageUseException.hxx"
9 #include "resiprocate/os/Logger.hxx"
10
11 using namespace resip;
12
13 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM
14
15 ServerInviteSession::ServerInviteSession(DialogUsageManager& dum, Dialog& dialog, const SipMessage& request)
16 : InviteSession(dum, dialog, Initial)
17 {
18 assert(request.isRequest());
19 mLastRequest = request;
20 }
21
22 ServerInviteSessionHandle
23 ServerInviteSession::getHandle()
24 {
25 return ServerInviteSessionHandle(mDum, getBaseHandle().getId());
26 }
27
28 SipMessage&
29 ServerInviteSession::end()
30 {
31 InfoLog ( << "ServerInviteSession::end" );
32 switch (mState)
33 {
34 case Accepting:
35 case Terminated:
36 case Connected:
37 return InviteSession::end();
38 break;
39 default:
40 return reject(410);
41 }
42 }
43
44 void
45 ServerInviteSession::send(SipMessage& msg)
46 {
47 if (mState == Accepting || mState == Connected || mState == Terminated)
48 {
49 InviteSession::send(msg);
50 return;
51 }
52
53 //!dcm! -- not considering prack, so offer/answer only happens in 2xx
54 if(msg.isResponse())
55 {
56 int code = msg.header(h_StatusLine).statusCode();
57 if (code < 200)
58 {
59 mDum.send(msg);
60 msg.releaseContents(); //!dcm! -- maybe?
61 }
62 else if (code < 300)
63 {
64 mState = Accepting;
65 if (msg.header(h_CSeq).method() == INVITE)
66 {
67 InviteSession::send(msg);
68 }
69 else
70 {
71 mDum.send(msg);
72 }
73 }
74 else
75 {
76 mDum.send(msg);
77 delete this;
78 }
79 }
80 else
81 {
82 //!dcm!-- accepting logic is in InviteSession(merge w/ reinvite),
83 //so no requests should be legal, which makes this user error? UPDATE eventually?
84 throw UsageUseException("No request legal in this context.", __FILE__, __LINE__);
85 }
86 }
87
88 SipMessage&
89 ServerInviteSession::provisional(int statusCode)
90 {
91 mDialog.makeResponse(mLastResponse, mLastRequest, statusCode);
92 return mLastResponse;
93 }
94
95 SipMessage&
96 ServerInviteSession::reject(int statusCode)
97 {
98 mDialog.makeResponse(mLastResponse, mLastRequest, statusCode);
99 return mLastResponse;
100 }
101
102 SipMessage&
103 ServerInviteSession::accept()
104 {
105 mDialog.makeResponse(mFinalResponse, mLastRequest, 200);
106 return mFinalResponse;
107 }
108
109 void
110 ServerInviteSession::dispatch(const SipMessage& msg)
111 {
112 std::pair<OfferAnswerType, const SdpContents*> offans;
113 offans = InviteSession::getOfferOrAnswer(msg);
114 if (msg.isRequest())
115 {
116 switch(mState)
117 {
118 case Initial:
119 assert(msg.header(h_RequestLine).method() == INVITE);
120 mState = Proceeding;
121 mDum.mInviteSessionHandler->onNewSession(getHandle(), offans.first, msg);
122
123 if (offans.first == Offer)
124 {
125 InviteSession::incomingSdp(msg, offans.second);
126 }
127 mLastRequest.releaseContents(); //!dcm! -- not sure, but seems right
128 break;
129 case Proceeding:
130 // !jf! consider UPDATE method
131 if (msg.header(h_RequestLine).method() == CANCEL)
132 {
133 mDialog.makeResponse(mLastResponse, msg, 200);
134 mDum.send(mLastResponse);
135 mDialog.makeResponse(mLastResponse, msg, 487);
136 mDum.send(mLastResponse);
137 }
138 else
139 {
140 assert(0); //!dcm! -- throw, toss away, inform other endpoint?
141 }
142 break;
143 default:
144 InviteSession::dispatch(msg);
145 }
146 }
147 else
148 {
149 InviteSession::dispatch(msg);
150 }
151 }
152
153
154
155 /* ====================================================================
156 * The Vovida Software License, Version 1.0
157 *
158 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
159 *
160 * Redistribution and use in source and binary forms, with or without
161 * modification, are permitted provided that the following conditions
162 * are met:
163 *
164 * 1. Redistributions of source code must retain the above copyright
165 * notice, this list of conditions and the following disclaimer.
166 *
167 * 2. Redistributions in binary form must reproduce the above copyright
168 * notice, this list of conditions and the following disclaimer in
169 * the documentation and/or other materials provided with the
170
171 * distribution.
172 *
173 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
174 * and "Vovida Open Communication Application Library (VOCAL)" must
175 * not be used to endorse or promote products derived from this
176 * software without prior written permission. For written
177 * permission, please contact vocal@vovida.org.
178 *
179 * 4. Products derived from this software may not be called "VOCAL", nor
180 * may "VOCAL" appear in their name, without prior written
181 * permission of Vovida Networks, Inc.
182 *
183 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
184 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
185 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
186 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
187 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
188 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
189 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
190 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
191 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
192 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
193 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
194 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
195 * DAMAGE.
196 *
197 * ====================================================================
198 *
199 * This software consists of voluntary contributions made by Vovida
200 * Networks, Inc. and many individuals on behalf of Vovida Networks,
201 * Inc. For more information on Vovida Networks, Inc., please see
202 * <http://www.vovida.org/>.
203 *
204 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27