2014-07-31 18:58:13 +08:00
|
|
|
/**
|
|
|
|
|
* DeferredGet.cpp
|
|
|
|
|
*
|
|
|
|
|
* Implementation of the DeferredGet call
|
|
|
|
|
*
|
|
|
|
|
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
|
2018-03-02 00:34:27 +08:00
|
|
|
* @copyright 2014 - 2018 Copernica BV
|
2014-07-31 18:58:13 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dependencies
|
|
|
|
|
*/
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
|
|
|
|
|
|
|
|
|
/**
|
2016-06-23 20:42:50 +08:00
|
|
|
* Report success for a get operation
|
|
|
|
|
* @param messagecount Number of messages left in the queue
|
|
|
|
|
* @param deliveryTag Delivery tag of the message coming in
|
|
|
|
|
* @param redelivered Was the message redelivered?
|
2014-07-31 18:58:13 +08:00
|
|
|
*/
|
2016-06-23 20:42:50 +08:00
|
|
|
const std::shared_ptr<Deferred> &DeferredGet::reportSuccess(uint32_t messagecount, uint64_t deliveryTag, bool redelivered)
|
2014-07-31 18:58:13 +08:00
|
|
|
{
|
2018-03-02 00:34:27 +08:00
|
|
|
// install this object as the handler for the upcoming header and body frames
|
|
|
|
|
_channel->install(shared_from_this());
|
|
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
// store delivery tag and redelivery status
|
|
|
|
|
_deliveryTag = deliveryTag;
|
|
|
|
|
_redelivered = redelivered;
|
2014-08-04 19:44:17 +08:00
|
|
|
|
2014-09-02 17:18:11 +08:00
|
|
|
// report the size (note that this is the size _minus_ the message that is retrieved
|
|
|
|
|
// (and for which the callback will be called later), so it could be zero)
|
2018-03-02 04:12:53 +08:00
|
|
|
if (_countCallback) _countCallback(messagecount);
|
2015-04-28 16:58:49 +08:00
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
// return next handler
|
2014-07-31 18:58:13 +08:00
|
|
|
return _next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-06-23 20:42:50 +08:00
|
|
|
* Report success, although no message could be gotten
|
2014-09-02 16:32:55 +08:00
|
|
|
* @return Deferred
|
2014-07-31 18:58:13 +08:00
|
|
|
*/
|
2014-09-02 16:32:55 +08:00
|
|
|
const std::shared_ptr<Deferred> &DeferredGet::reportSuccess() const
|
2014-07-31 18:58:13 +08:00
|
|
|
{
|
2014-08-28 16:02:01 +08:00
|
|
|
// report the size
|
2018-03-02 04:12:53 +08:00
|
|
|
if (_countCallback) _countCallback(0);
|
2014-08-28 16:02:01 +08:00
|
|
|
|
2014-07-31 18:58:13 +08:00
|
|
|
// check if a callback was set
|
|
|
|
|
if (_emptyCallback) _emptyCallback();
|
2015-04-28 16:58:49 +08:00
|
|
|
|
2014-07-31 18:58:13 +08:00
|
|
|
// return next object
|
|
|
|
|
return _next;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
/**
|
2018-03-02 00:34:27 +08:00
|
|
|
* Extended implementation of the complete method that is called when a message was fully received
|
2016-06-23 20:42:50 +08:00
|
|
|
*/
|
2018-03-02 00:34:27 +08:00
|
|
|
void DeferredGet::complete()
|
2016-06-23 20:42:50 +08:00
|
|
|
{
|
2018-03-02 00:34:27 +08:00
|
|
|
// the channel is now synchronized, delayed frames may now be sent
|
2019-06-19 16:54:50 +08:00
|
|
|
_channel->flush();
|
2018-03-02 00:34:27 +08:00
|
|
|
|
|
|
|
|
// pass on to normal implementation
|
2018-03-02 01:07:18 +08:00
|
|
|
DeferredExtReceiver::complete();
|
2016-06-23 20:42:50 +08:00
|
|
|
}
|
|
|
|
|
|
2014-07-31 18:58:13 +08:00
|
|
|
/**
|
|
|
|
|
* End of namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|