/[resiprocate]/main/resip/dum/test/basicClientUserAgent.hxx
ViewVC logotype

Contents of /main/resip/dum/test/basicClientUserAgent.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9739 - (show annotations) (download)
Thu May 31 15:58:53 2012 UTC (7 years, 7 months ago) by sgodin
File MIME type: text/plain
File size: 10994 byte(s)
-fixed a trap during shutdown, due to order of destructed objects
1 #if !defined(basicClientUserAgent_hxx)
2 #define basicClientUserAgent_hxx
3
4 #include <set>
5 #include "basicClientCmdLineParser.hxx"
6
7 #include "resip/stack/InterruptableStackThread.hxx"
8 #include "rutil/SelectInterruptor.hxx"
9 #include "resip/dum/MasterProfile.hxx"
10 #include "resip/dum/RegistrationHandler.hxx"
11 #include "resip/dum/SubscriptionHandler.hxx"
12 #include "resip/dum/RedirectHandler.hxx"
13 #include "resip/dum/DialogSetHandler.hxx"
14 #include "resip/dum/DumShutdownHandler.hxx"
15 #include "resip/dum/OutOfDialogHandler.hxx"
16 #include "resip/dum/InviteSessionHandler.hxx"
17 #include "resip/dum/DialogUsageManager.hxx"
18 #include "resip/dum/Postable.hxx"
19
20 namespace resip
21 {
22 class BasicClientCall;
23
24 class BasicClientUserAgent : public BasicClientCmdLineParser,
25 public Postable,
26 public DialogSetHandler,
27 public ClientRegistrationHandler,
28 public ClientSubscriptionHandler,
29 public ServerSubscriptionHandler,
30 public OutOfDialogHandler,
31 public InviteSessionHandler,
32 public DumShutdownHandler,
33 public RedirectHandler
34 {
35 public:
36 BasicClientUserAgent(int argc, char** argv);
37 virtual ~BasicClientUserAgent();
38
39 virtual void startup();
40 virtual void shutdown();
41 bool process(int timeoutMs); // returns false when shutdown is complete and process should no longer be called
42
43 DialogUsageManager& getDialogUsageManager() { return *mDum; }
44 SharedPtr<UserProfile> getIncomingUserProfile(const SipMessage& msg) { return mProfile; } // This test program only uses the one global Master Profile - just return it
45
46 protected:
47 // Postable Handler ////////////////////////////////////////////////////////////
48 virtual void post(Message*); // Used to receive Connection Terminated messages
49
50 // Shutdown Handler ////////////////////////////////////////////////////////////
51 void onDumCanBeDeleted();
52
53 // Registration Handler ////////////////////////////////////////////////////////
54 virtual void onSuccess(resip::ClientRegistrationHandle h, const resip::SipMessage& response);
55 virtual void onFailure(resip::ClientRegistrationHandle h, const resip::SipMessage& response);
56 virtual void onRemoved(resip::ClientRegistrationHandle h, const resip::SipMessage& response);
57 virtual int onRequestRetry(resip::ClientRegistrationHandle h, int retryMinimum, const resip::SipMessage& msg);
58
59 // ClientSubscriptionHandler ///////////////////////////////////////////////////
60 virtual void onUpdatePending(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
61 virtual void onUpdateActive(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
62 virtual void onUpdateExtension(resip::ClientSubscriptionHandle, const resip::SipMessage& notify, bool outOfOrder);
63 virtual void onNotifyNotReceived(ClientSubscriptionHandle h);
64 virtual void onTerminated(resip::ClientSubscriptionHandle h, const resip::SipMessage* notify);
65 virtual void onNewSubscription(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify);
66 virtual int onRequestRetry(resip::ClientSubscriptionHandle h, int retrySeconds, const resip::SipMessage& notify);
67
68 // Invite Session Handler /////////////////////////////////////////////////////
69 virtual void onNewSession(resip::ClientInviteSessionHandle h, resip::InviteSession::OfferAnswerType oat, const resip::SipMessage& msg);
70 virtual void onNewSession(resip::ServerInviteSessionHandle h, resip::InviteSession::OfferAnswerType oat, const resip::SipMessage& msg);
71 virtual void onFailure(resip::ClientInviteSessionHandle h, const resip::SipMessage& msg);
72 virtual void onEarlyMedia(resip::ClientInviteSessionHandle, const resip::SipMessage&, const resip::SdpContents&);
73 virtual void onProvisional(resip::ClientInviteSessionHandle, const resip::SipMessage& msg);
74 virtual void onConnected(resip::ClientInviteSessionHandle h, const resip::SipMessage& msg);
75 virtual void onConnected(resip::InviteSessionHandle, const resip::SipMessage& msg);
76 virtual void onStaleCallTimeout(resip::ClientInviteSessionHandle);
77 virtual void onTerminated(resip::InviteSessionHandle h, resip::InviteSessionHandler::TerminatedReason reason, const resip::SipMessage* msg);
78 virtual void onRedirected(resip::ClientInviteSessionHandle, const resip::SipMessage& msg);
79 virtual void onAnswer(resip::InviteSessionHandle, const resip::SipMessage& msg, const resip::SdpContents&);
80 virtual void onOffer(resip::InviteSessionHandle handle, const resip::SipMessage& msg, const resip::SdpContents& offer);
81 virtual void onOfferRequired(resip::InviteSessionHandle, const resip::SipMessage& msg);
82 virtual void onOfferRejected(resip::InviteSessionHandle, const resip::SipMessage* msg);
83 virtual void onOfferRequestRejected(resip::InviteSessionHandle, const resip::SipMessage& msg);
84 virtual void onRemoteSdpChanged(resip::InviteSessionHandle, const resip::SipMessage& msg, const resip::SdpContents& sdp);
85 virtual void onInfo(resip::InviteSessionHandle, const resip::SipMessage& msg);
86 virtual void onInfoSuccess(resip::InviteSessionHandle, const resip::SipMessage& msg);
87 virtual void onInfoFailure(resip::InviteSessionHandle, const resip::SipMessage& msg);
88 virtual void onRefer(resip::InviteSessionHandle, resip::ServerSubscriptionHandle, const resip::SipMessage& msg);
89 virtual void onReferAccepted(resip::InviteSessionHandle, resip::ClientSubscriptionHandle, const resip::SipMessage& msg);
90 virtual void onReferRejected(resip::InviteSessionHandle, const resip::SipMessage& msg);
91 virtual void onReferNoSub(resip::InviteSessionHandle, const resip::SipMessage& msg);
92 virtual void onMessage(resip::InviteSessionHandle, const resip::SipMessage& msg);
93 virtual void onMessageSuccess(resip::InviteSessionHandle, const resip::SipMessage& msg);
94 virtual void onMessageFailure(resip::InviteSessionHandle, const resip::SipMessage& msg);
95 virtual void onForkDestroyed(resip::ClientInviteSessionHandle);
96 virtual void onReadyToSend(InviteSessionHandle, SipMessage& msg);
97 virtual void onFlowTerminated(InviteSessionHandle);
98
99 // DialogSetHandler //////////////////////////////////////////////
100 virtual void onTrying(resip::AppDialogSetHandle, const resip::SipMessage& msg);
101 virtual void onNonDialogCreatingProvisional(resip::AppDialogSetHandle, const resip::SipMessage& msg);
102
103 // ServerSubscriptionHandler ///////////////////////////////////////////////////
104 virtual void onNewSubscription(resip::ServerSubscriptionHandle, const resip::SipMessage& sub);
105 virtual void onNewSubscriptionFromRefer(resip::ServerSubscriptionHandle, const resip::SipMessage& sub);
106 virtual void onRefresh(resip::ServerSubscriptionHandle, const resip::SipMessage& sub);
107 virtual void onTerminated(resip::ServerSubscriptionHandle);
108 virtual void onReadyToSend(resip::ServerSubscriptionHandle, resip::SipMessage&);
109 virtual void onNotifyRejected(resip::ServerSubscriptionHandle, const resip::SipMessage& msg);
110 virtual void onError(resip::ServerSubscriptionHandle, const resip::SipMessage& msg);
111 virtual void onExpiredByClient(resip::ServerSubscriptionHandle, const resip::SipMessage& sub, resip::SipMessage& notify);
112 virtual void onExpired(resip::ServerSubscriptionHandle, resip::SipMessage& notify);
113 virtual bool hasDefaultExpires() const;
114 virtual UInt32 getDefaultExpires() const;
115
116 // OutOfDialogHandler //////////////////////////////////////////////////////////
117 virtual void onSuccess(resip::ClientOutOfDialogReqHandle, const resip::SipMessage& response);
118 virtual void onFailure(resip::ClientOutOfDialogReqHandle, const resip::SipMessage& response);
119 virtual void onReceivedRequest(resip::ServerOutOfDialogReqHandle, const resip::SipMessage& request);
120
121 // RedirectHandler /////////////////////////////////////////////////////////////
122 virtual void onRedirectReceived(resip::AppDialogSetHandle, const resip::SipMessage& response);
123 virtual bool onTryingNextTarget(resip::AppDialogSetHandle, const resip::SipMessage& request);
124
125 protected:
126 void addTransport(TransportType type, int port);
127 friend class NotifyTimer;
128 void onNotifyTimeout(unsigned int timerId);
129 void sendNotify();
130 friend class CallTimer;
131 void onCallTimeout(BasicClientCall* call);
132
133 SharedPtr<MasterProfile> mProfile;
134 // Using pointers for the following classes so that we can control object descruction order
135 Security* mSecurity;
136 SelectInterruptor* mSelectInterruptor;
137 SipStack* mStack;
138 InterruptableStackThread* mStackThread;
139 DialogUsageManager* mDum;
140 volatile bool mDumShutdownRequested;
141 bool mDumShutdown;
142 ClientRegistrationHandle mRegHandle;
143 ClientSubscriptionHandle mClientSubscriptionHandle;
144 ServerSubscriptionHandle mServerSubscriptionHandle;
145 unsigned int mRegistrationRetryDelayTime;
146 unsigned int mCurrentNotifyTimerId;
147
148 friend class BasicClientCall;
149 std::set<BasicClientCall*> mCallList;
150 void registerCall(BasicClientCall* call);
151 void unregisterCall(BasicClientCall* call);
152 bool isValidCall(BasicClientCall* call);
153 };
154
155 }
156
157 #endif
158
159 /* ====================================================================
160
161 Copyright (c) 2011, SIP Spectrum, Inc.
162 All rights reserved.
163
164 Redistribution and use in source and binary forms, with or without
165 modification, are permitted provided that the following conditions are
166 met:
167
168 1. Redistributions of source code must retain the above copyright
169 notice, this list of conditions and the following disclaimer.
170
171 2. Redistributions in binary form must reproduce the above copyright
172 notice, this list of conditions and the following disclaimer in the
173 documentation and/or other materials provided with the distribution.
174
175 3. Neither the name of SIP Spectrum nor the names of its contributors
176 may be used to endorse or promote products derived from this
177 software without specific prior written permission.
178
179 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
180 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
183 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
184 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
185 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
186 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
187 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
188 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
189 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
190
191 ==================================================================== */
192

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27