Copied the methods to both implementations so they can return their concrete type
This commit is contained in:
parent
434a0fad52
commit
ba6b3e2923
|
|
@ -72,6 +72,58 @@ public:
|
|||
DeferredConsumerBase(failed, channel) {}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Register the function to be called when a new message is expected
|
||||
*
|
||||
* @param callback The callback to invoke
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumer &onBegin(const BeginCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_beginCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function to be called when message headers come in
|
||||
*
|
||||
* @param callback The callback to invoke for message headers
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumer &onHeaders(const HeaderCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_headerCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function to be called when a chunk of data comes in
|
||||
*
|
||||
* Note that this function may be called zero, one or multiple times
|
||||
* for each incoming message depending on the size of the message data.
|
||||
*
|
||||
* If you install this callback you very likely also want to install
|
||||
* the onComplete callback so you know when the last data part was
|
||||
* received.
|
||||
*
|
||||
* @param callback The callback to invoke for chunks of message data
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumer &onData(const DataCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_dataCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function that is called when the consumer starts
|
||||
* @param callback
|
||||
|
|
@ -125,6 +177,21 @@ public:
|
|||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a funtion to be called when a message was completely received
|
||||
*
|
||||
* @param callback The callback to invoke
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumer &onComplete(const CompleteCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_completeCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -150,100 +150,6 @@ protected:
|
|||
*/
|
||||
DeferredConsumerBase(bool failed, ChannelImpl *channel) : Deferred(failed), _channel(channel) {}
|
||||
public:
|
||||
/**
|
||||
* Register the function to be called when a new message is expected
|
||||
*
|
||||
* @param callback The callback to invoke
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumerBase &onBegin(const BeginCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_beginCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function to be called when message headers come in
|
||||
*
|
||||
* @param callback The callback to invoke for message headers
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumerBase &onHeaders(const HeaderCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_headerCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function to be called when a chunk of data comes in
|
||||
*
|
||||
* Note that this function may be called zero, one or multiple times
|
||||
* for each incoming message depending on the size of the message data.
|
||||
*
|
||||
* If you install this callback you very likely also want to install
|
||||
* the onComplete callback so you know when the last data part was
|
||||
* received.
|
||||
*
|
||||
* @param callback The callback to invoke for chunks of message data
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumerBase &onData(const DataCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_dataCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be called when a message arrives
|
||||
* This fuction is also available as onSuccess() and onMessage() because I always forget which name I gave to it
|
||||
* @param callback the callback to execute
|
||||
*/
|
||||
DeferredConsumerBase &onReceived(const MessageCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_messageCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be called when a message arrives
|
||||
* This fuction is also available as onSuccess() and onReceived() because I always forget which name I gave to it
|
||||
* @param callback the callback to execute
|
||||
*/
|
||||
DeferredConsumerBase &onMessage(const MessageCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_messageCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a funtion to be called when a message was completely received
|
||||
*
|
||||
* @param callback The callback to invoke
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredConsumerBase& onComplete(const CompleteCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_completeCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -89,6 +89,58 @@ public:
|
|||
DeferredConsumerBase(failed, channel) {}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Register the function to be called when a new message is expected
|
||||
*
|
||||
* @param callback The callback to invoke
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredGet &onBegin(const BeginCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_beginCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function to be called when message headers come in
|
||||
*
|
||||
* @param callback The callback to invoke for message headers
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredGet &onHeaders(const HeaderCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_headerCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the function to be called when a chunk of data comes in
|
||||
*
|
||||
* Note that this function may be called zero, one or multiple times
|
||||
* for each incoming message depending on the size of the message data.
|
||||
*
|
||||
* If you install this callback you very likely also want to install
|
||||
* the onComplete callback so you know when the last data part was
|
||||
* received.
|
||||
*
|
||||
* @param callback The callback to invoke for chunks of message data
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredGet &onData(const DataCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_dataCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be called when a message arrives
|
||||
* This fuction is also available as onReceived() and onMessage() because I always forget which name I gave to it
|
||||
|
|
@ -103,6 +155,34 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be called when a message arrives
|
||||
* This fuction is also available as onSuccess() and onMessage() because I always forget which name I gave to it
|
||||
* @param callback the callback to execute
|
||||
*/
|
||||
DeferredGet &onReceived(const MessageCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_messageCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be called when a message arrives
|
||||
* This fuction is also available as onSuccess() and onReceived() because I always forget which name I gave to it
|
||||
* @param callback the callback to execute
|
||||
*/
|
||||
DeferredGet &onMessage(const MessageCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_messageCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be called if no message could be fetched
|
||||
* @param callback the callback to execute
|
||||
|
|
@ -128,6 +208,21 @@ public:
|
|||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a funtion to be called when a message was completely received
|
||||
*
|
||||
* @param callback The callback to invoke
|
||||
* @return Same object for chaining
|
||||
*/
|
||||
DeferredGet &onComplete(const CompleteCallback &callback)
|
||||
{
|
||||
// store callback
|
||||
_completeCallback = callback;
|
||||
|
||||
// allow chaining
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue