reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ClientSubscription.hxx
Go to the documentation of this file.
1#if !defined(RESIP_CLIENTSUBSCRIPTION_HXX)
2#define RESIP_CLIENTSUBSCRIPTION_HXX
3
4#include <deque>
6
7namespace resip
8{
9
10class DialogUsageManager;
11
13
15{
16 public:
17 ClientSubscription(DialogUsageManager& dum, Dialog& dialog, const SipMessage& request);
20
23
26
27 //.dcm. no adornment for ease of use, can add if there is a use case
28 void acceptUpdate(int statusCode = 200, const char* reason = nullptr);
29 void rejectUpdate(int statusCode = 400, const Data& reasonPhrase = Data::Empty);
30 void requestRefresh(uint32_t expires = 0); // 0 defaults to using original expires value (to remove call end() instead)
31 void end() override;
32 void end(bool immediate); // If immediate is true then usage is destroyed with no further messaging
33 virtual void reSubscribe(); // forms a new Subscription dialog - reusing the same target and AppDialogSet
37 void acceptUpdateCommand(int statusCode = 200, const char* reason = nullptr);
38 void rejectUpdateCommand(int statusCode = 400, const Data& reasonPhrase = Data::Empty);
39 void requestRefreshCommand(uint32_t expires = 0); // 0 defaults to using original expires value (to remove call endCommand() instead)
40 virtual void endCommand(bool immediate=false); // If immediate is true then usage is destroyed with no further messaging
41
42 EncodeStream& dump(EncodeStream& strm) const override;
43
44 protected:
45 virtual ~ClientSubscription();
46 virtual void onReadyToSend(SipMessage& msg) override;
47 virtual void send(std::shared_ptr<SipMessage> msg) override;
48 virtual void flowTerminated();
49
50 private:
51 friend class Dialog;
52 friend class InviteSession;
53
54 class QueuedNotify
55 {
56 public:
57 QueuedNotify(const SipMessage& notify, bool outOfOrder)
58 : mNotify(notify), mOutOfOrder(outOfOrder) {}
59
60 SipMessage& notify() noexcept { return mNotify; }
61 bool outOfOrder() const noexcept { return mOutOfOrder; }
62
63 private:
64 SipMessage mNotify;
65 bool mOutOfOrder;
66 };
67
68 typedef std::deque<QueuedNotify*> NotifyQueue;
69 NotifyQueue mQueuedNotifies;
70
71 typedef std::vector<QueuedNotify*> Dustbin;
72 Dustbin mDustbin;
73
74 bool mOnNewSubscriptionCalled;
75 bool mEnded;
76 // .bwc. This is when our next reSUB is scheduled to happen.
77 uint64_t mNextRefreshSecs;
78 uint64_t mLastSubSecs;
79
80 bool mSubscribed;
81 bool mRefreshing;
82 bool mHaveQueuedRefresh;
83 int mQueuedRefreshInterval;
84
85 unsigned int mLargestNotifyCSeq;
86
87 void dispatch(const SipMessage& msg) override;
88 void dispatch(const DumTimeout& timer) override;
89
90 void sendQueuedRefreshRequest();
91 void processNextNotify();
92 void processResponse(const SipMessage& response);
93 void clearDustbin();
94 void scheduleRefresh(unsigned long refreshInterval);
95};
96
97}
98
99#endif
100
101/* ====================================================================
102 * The Vovida Software License, Version 1.0
103 *
104 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
105 *
106 * Redistribution and use in source and binary forms, with or without
107 * modification, are permitted provided that the following conditions
108 * are met:
109 *
110 * 1. Redistributions of source code must retain the above copyright
111 * notice, this list of conditions and the following disclaimer.
112 *
113 * 2. Redistributions in binary form must reproduce the above copyright
114 * notice, this list of conditions and the following disclaimer in
115 * the documentation and/or other materials provided with the
116 * distribution.
117 *
118 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
119 * and "Vovida Open Communication Application Library (VOCAL)" must
120 * not be used to endorse or promote products derived from this
121 * software without prior written permission. For written
122 * permission, please contact vocal@vovida.org.
123 *
124 * 4. Products derived from this software may not be called "VOCAL", nor
125 * may "VOCAL" appear in their name, without prior written
126 * permission of Vovida Networks, Inc.
127 *
128 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
129 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
130 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
131 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
132 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
133 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
134 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
135 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
136 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
137 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
138 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
139 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
140 * DAMAGE.
141 *
142 * ====================================================================
143 *
144 * This software consists of voluntary contributions made by Vovida
145 * Networks, Inc. and many individuals on behalf of Vovida Networks,
146 * Inc. For more information on Vovida Networks, Inc., please see
147 * <http://www.vovida.org/>.
148 *
149 */
dcm! – update contact in dialog if required
dcm! – update contact in dialog if required
ClientSubscription & operator=(ClientSubscription &&)=delete
void acceptUpdate(int statusCode=200, const char *reason=nullptr)
ClientSubscription(ClientSubscription &&)=delete
void requestRefreshCommand(uint32_t expires=0)
virtual void onReadyToSend(SipMessage &msg) override
EncodeStream & dump(EncodeStream &strm) const override
void rejectUpdateCommand(int statusCode=400, const Data &reasonPhrase=Data::Empty)
Handle< ClientSubscription > ClientSubscriptionHandle
void acceptUpdateCommand(int statusCode=200, const char *reason=nullptr)
Provide asynchronous method access by using command.
ClientSubscription & operator=(const ClientSubscription &)=delete
void requestRefresh(uint32_t expires=0)
virtual void send(std::shared_ptr< SipMessage > msg) override
virtual void endCommand(bool immediate=false)
void rejectUpdate(int statusCode=400, const Data &reasonPhrase=Data::Empty)
ClientSubscription(const ClientSubscription &)=delete
ClientSubscriptionHandle getHandle()
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
dcm! – kill typedef std::list<DialogId> DialogIdSet;
Definition Dialog.hxx:29
Base class for class ClientInviteSession and class ServerInviteSession.
Represents a SIP message.
dcm! – add UnusedChecking(_enum) below;
unsigned int uint32_t
Definition Stun.hxx:34
#define EncodeStream
unsigned __int64 uint64_t
Definition stdint.h:95