2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Class describing a basic cancel frame
|
|
|
|
|
*
|
|
|
|
|
* @copyright 2014 Copernica BV
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class implementation
|
|
|
|
|
*/
|
|
|
|
|
class BasicCancelFrame : public BasicFrame
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
/**
|
|
|
|
|
* Holds the consumer tag specified by the client or provided by the server.
|
|
|
|
|
* @var ShortString
|
|
|
|
|
*/
|
|
|
|
|
ShortString _consumerTag;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* whether to wait for a response
|
|
|
|
|
* @var BooleanSet
|
|
|
|
|
*/
|
|
|
|
|
BooleanSet _noWait;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
|
|
|
|
* Encode a frame on a string buffer
|
|
|
|
|
*
|
|
|
|
|
* @param buffer buffer to write frame to
|
|
|
|
|
*/
|
|
|
|
|
virtual void fill(OutBuffer& buffer) const override
|
|
|
|
|
{
|
|
|
|
|
// call base
|
|
|
|
|
BasicFrame::fill(buffer);
|
|
|
|
|
|
|
|
|
|
// add consumer tag + booleans
|
|
|
|
|
_consumerTag.fill(buffer);
|
|
|
|
|
_noWait.fill(buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Construct a basic cancel frame from a received frame
|
|
|
|
|
*
|
|
|
|
|
* @param frame received frame to parse
|
|
|
|
|
*/
|
|
|
|
|
BasicCancelFrame(ReceivedFrame &frame) : BasicFrame(frame), _consumerTag(frame), _noWait(frame) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct a basic cancel frame
|
|
|
|
|
*
|
|
|
|
|
* @param channel Channel identifier
|
|
|
|
|
* @param consumerTag consumertag specified by client of provided by server
|
|
|
|
|
* @param noWait whether to wait for a response.
|
|
|
|
|
*/
|
|
|
|
|
BasicCancelFrame(uint16_t channel, const std::string& consumerTag, bool noWait = false) :
|
2018-01-23 23:47:53 +08:00
|
|
|
BasicFrame(channel, (uint32_t)(consumerTag.size() + 2)), // 1 for extra string size, 1 for bool
|
2014-01-04 19:45:04 +08:00
|
|
|
_consumerTag(consumerTag),
|
|
|
|
|
_noWait(noWait) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
virtual ~BasicCancelFrame() {}
|
2014-04-29 21:51:33 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Is this a synchronous frame?
|
|
|
|
|
*
|
|
|
|
|
* After a synchronous frame no more frames may be
|
|
|
|
|
* sent until the accompanying -ok frame arrives
|
|
|
|
|
*/
|
|
|
|
|
bool synchronous() const override
|
|
|
|
|
{
|
|
|
|
|
// we are synchronous when the nowait option is not used
|
|
|
|
|
return !noWait();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Return the consumertag, which is specified by the client or provided by the server
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
const std::string& consumerTag() const
|
|
|
|
|
{
|
|
|
|
|
return _consumerTag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the method ID
|
|
|
|
|
* @return uint16_t
|
|
|
|
|
*/
|
|
|
|
|
virtual uint16_t methodID() const override
|
|
|
|
|
{
|
|
|
|
|
return 30;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether to wait for a response
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2016-09-03 03:44:11 +08:00
|
|
|
bool noWait() const
|
2014-01-04 19:45:04 +08:00
|
|
|
{
|
|
|
|
|
return _noWait.get(0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* end namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|