/[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 10878 - (show annotations) (download)
Sat Jan 18 16:59:54 2014 UTC (5 years, 10 months ago) by sgodin
File MIME type: text/plain
File size: 11002 byte(s)
-modified basicClient to use EventStackThread instead of InterruptableStackThread
 -enables Epoll support on platforms that support it
1 #if !defined(basicClientUserAgent_hxx)
2 #define basicClientUserAgent_hxx
3
4 #include <set>
5 #include "basicClientCmdLineParser.hxx"
6
7 #include "resip/stack/EventStackThread.hxx"
8 #include "resip/dum/MasterProfile.hxx"
9 #include "resip/dum/RegistrationHandler.hxx"
10 #include "resip/dum/SubscriptionHandler.hxx"
11 #include "resip/dum/RedirectHandler.hxx"
12 #include "resip/dum/DialogSetHandler.hxx"
13 #include "resip/dum/DumShutdownHandler.hxx"
14 #include "resip/dum/OutOfDialogHandler.hxx"
15 #include "resip/dum/InviteSessionHandler.hxx"
16 #include "resip/dum/DialogUsageManager.hxx"
17 #include "resip/dum/Postable.hxx"
18
19 namespace resip
20 {
21 class BasicClientCall;
22 class FdPollGrp;
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 FdPollGrp* mPollGrp;
137 EventThreadInterruptor* mInterruptor;
138 SipStack* mStack;
139 EventStackThread* mStackThread;
140 DialogUsageManager* mDum;
141 volatile bool mDumShutdownRequested;
142 bool mShuttingdown;
143 bool mDumShutdown;
144 ClientRegistrationHandle mRegHandle;
145 ClientSubscriptionHandle mClientSubscriptionHandle;
146 ServerSubscriptionHandle mServerSubscriptionHandle;
147 unsigned int mRegistrationRetryDelayTime;
148 unsigned int mCurrentNotifyTimerId;
149
150 friend class BasicClientCall;
151 std::set<BasicClientCall*> mCallList;
152 void registerCall(BasicClientCall* call);
153 void unregisterCall(BasicClientCall* call);
154 bool isValidCall(BasicClientCall* call);
155 };
156
157 }
158
159 #endif
160
161 /* ====================================================================
162
163 Copyright (c) 2011, SIP Spectrum, Inc.
164 All rights reserved.
165
166 Redistribution and use in source and binary forms, with or without
167 modification, are permitted provided that the following conditions are
168 met:
169
170 1. Redistributions of source code must retain the above copyright
171 notice, this list of conditions and the following disclaimer.
172
173 2. Redistributions in binary form must reproduce the above copyright
174 notice, this list of conditions and the following disclaimer in the
175 documentation and/or other materials provided with the distribution.
176
177 3. Neither the name of SIP Spectrum nor the names of its contributors
178 may be used to endorse or promote products derived from this
179 software without specific prior written permission.
180
181 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
183 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
184 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
185 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
186 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
187 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
188 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
189 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
190 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
191 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
192
193 ==================================================================== */
194

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