14#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
26 std::shared_ptr<SipMessage> req)
29 mWaitingForResponse(false),
30 mPendingPublish(false),
33 mEventType(mPublish->header(h_Event).value()),
35 mDocument(mPublish->releaseContents().release())
37 DebugLog( <<
"ClientPublication::ClientPublication: " <<
mId);
42 DebugLog( <<
"ClientPublication::~ClientPublication: " <<
mId);
62 if (mWaitingForResponse)
64 InfoLog(<<
"Waiting for response, pending End of client publication to " << mPublish->header(
h_RequestLine).uri());
71 mPublish->header(h_Expires).value() = 0;
72 mPublish->releaseContents();
77 InfoLog(<<
"End client publication immediately (not published) to " << mPublish->header(
h_RequestLine).uri());
86 : mClientPublicationHandle(clientPublicationHandle), mImmediate(immediate)
92 if(mClientPublicationHandle.isValid())
94 mClientPublicationHandle->end(mImmediate);
100 return strm <<
"ClientPublicationEndCommand";
121 DebugLog( <<
"Dropping stray request to ClientPublication usage: " << msg);
132 mWaitingForResponse =
false;
137 if (mPublish->exists(h_Expires) && mPublish->header(h_Expires).value() == 0)
143 else if (msg.
exists(h_SIPETag) && msg.
exists(h_Expires))
145 mPublish->header(h_SIPIfMatch) = msg.
header(h_SIPETag);
148 mPublish->releaseContents();
160 WarningLog (<<
"PUBLISH/200 received with no ETag " << mPublish->header(h_From).uri());
170 InfoLog(<<
"SIPIfMatch failed -- republish");
171 mPublish->remove(h_SIPIfMatch);
175 else if (code == 423)
177 if (msg.
exists(h_MinExpires))
179 mPublish->header(h_Expires).value() = msg.
header(h_MinExpires).value();
189 else if (code == 408 ||
199 msg.
exists(h_RetryAfter)))
201 int retryMinimum = 0;
202 if (msg.
exists(h_RetryAfter))
204 retryMinimum = msg.
header(h_RetryAfter).value();
211 DebugLog(<<
"Application requested failure on Retry-After");
216 else if (retry == 0 && retryMinimum == 0)
218 DebugLog(<<
"Application requested immediate retry on Retry-After");
224 retry =
resipMax(retry, retryMinimum);
225 DebugLog(<<
"Application requested delayed retry on Retry-After: " << retry);
246 mPublish->header(h_Expires).value() = 0;
247 mPublish->releaseContents();
248 InfoLog(<<
"Sending pending end PUBLISH: " << mPublish->brief());
253 InfoLog(<<
"Pending end PUBLISH, but not published, so ending immediately: " << mPublish->brief());
258 else if (mPendingPublish)
260 InfoLog (<<
"Sending pending PUBLISH: " << mPublish->brief());
269 if (timer.
seq() == mTimerSeq)
280 mPublish->header(h_Expires).value() = expiration;
289 : mClientPublicationHandle(clientPublicationHandle),
290 mExpiration(expiration)
296 if(mClientPublicationHandle.isValid())
298 mClientPublicationHandle->refresh(mExpiration);
304 return strm <<
"ClientPublicationRefreshCommand";
309 unsigned int mExpiration;
321 InfoLog (<<
"Updating presence document: " << mPublish->header(h_To).uri());
323 if (mDocument != body)
328 mDocument = body->
clone();
336 mPublish->setContents(mDocument);
344 : mClientPublicationHandle(clientPublicationHandle),
345 mBody(body ? body->clone() : nullptr)
351 if(mClientPublicationHandle.isValid())
353 mClientPublicationHandle->update(mBody.get());
359 return strm <<
"ClientPublicationUpdateCommand";
364 std::unique_ptr<Contents> mBody;
376 if (mWaitingForResponse)
378 mPendingPublish =
true;
382 request->header(h_CSeq).sequence()++;
384 mWaitingForResponse =
true;
385 mPendingPublish =
false;
392 strm <<
"ClientPublication " <<
mId <<
" " << mPublish->header(h_From).uri();
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
EncodeStream & encodeBrief(EncodeStream &strm) const override
output a brief description to stream
ClientPublicationEndCommand(const ClientPublicationHandle &clientPublicationHandle, bool immediate)
void executeCommand() override
void executeCommand() override
EncodeStream & encodeBrief(EncodeStream &strm) const override
output a brief description to stream
ClientPublicationRefreshCommand(const ClientPublicationHandle &clientPublicationHandle, unsigned int expiration)
void executeCommand() override
EncodeStream & encodeBrief(EncodeStream &strm) const override
output a brief description to stream
ClientPublicationUpdateCommand(const ClientPublicationHandle &clientPublicationHandle, const Contents *body)
BaseUsageHandle getBaseHandle() const
DialogUsageManager & mDum
virtual void onRemove(ClientPublicationHandle, const SipMessage &status)=0
virtual int onRequestRetry(ClientPublicationHandle, int retrySeconds, const SipMessage &status)=0
call on Retry-After failure.
virtual void onSuccess(ClientPublicationHandle, const SipMessage &status)=0
Called when the publication succeeds or each time it is successfully refreshed.
virtual void onFailure(ClientPublicationHandle, const SipMessage &status)=0
ClientPublication(DialogUsageManager &dum, DialogSet &dialogSet, std::shared_ptr< SipMessage > pub)
void updateCommand(const Contents *body)
Provide asynchronous method access by using command.
void refresh(unsigned int expiration=0)
void send(std::shared_ptr< SipMessage > request) override
virtual ~ClientPublication()
virtual void endCommand(bool immediate=false)
Handle< ClientPublication > ClientPublicationHandle
void refreshCommand(unsigned int expiration=0)
EncodeStream & dump(EncodeStream &strm) const override
void update(const Contents *body)
void dispatch(const SipMessage &msg) override
ClientPublicationHandle getHandle()
Base class for all SIP body types.
virtual Contents * clone() const =0
returns a copy of a Contents object
void send(std::shared_ptr< SipMessage > request)
ClientPublicationHandler * getClientPublicationHandler(const Data &eventType)
static T aBitSmallerThan(T secs)
Used by Registration, Publication and Subscription refreshes, to calculate the time at which a refres...
Represents a SIP message.
bool isRequest() const
Returns true if message is a request, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
bool isFromWire() const
Check if SipMessage came off the wire.
void post(Message *msg)
Posts a Message to this TransactionUser's fifo.
dcm! – add UnusedChecking(_enum) below;
StatusLineType h_StatusLine
RequestLineType h_RequestLine
const _Tp & resipMax(const _Tp &__a, const _Tp &__b)