1
0
mirror of https://github.com/eclipse/paho.mqtt.cpp.git synced 2025-05-09 11:21:24 +08:00

#411 Missing virtual keyword for some client methods

This commit is contained in:
fpagliughi 2023-11-12 20:04:14 -05:00
parent bb66355be6
commit 94efd557b4
4 changed files with 44 additions and 9 deletions

View File

@ -697,26 +697,26 @@ public:
* This initializes the client to receive messages through a queue that
* can be read synchronously.
*/
void start_consuming();
void start_consuming() override;
/**
* Stop consuming messages.
* This shuts down the internal callback and discards any unread
* messages.
*/
void stop_consuming();
void stop_consuming() override;
/**
* Read the next message from the queue.
* This blocks until a new message arrives.
* @return The message and topic.
*/
const_message_ptr consume_message() { return que_->get(); }
const_message_ptr consume_message() override { return que_->get(); }
/**
* Try to read the next message from the queue without blocking.
* @param msg Pointer to the value to receive the message
* @return @em true is a message was read, @em false if no message was
* available.
*/
bool try_consume_message(const_message_ptr* msg) {
bool try_consume_message(const_message_ptr* msg) override {
return que_->try_get(msg);
}
/**

View File

@ -377,26 +377,26 @@ public:
* This initializes the client to receive messages through a queue that
* can be read synchronously.
*/
void start_consuming() { cli_.start_consuming(); }
virtual void start_consuming() { cli_.start_consuming(); }
/**
* Stop consuming messages.
* This shuts down the internal callback and discards any unread
* messages.
*/
void stop_consuming() { cli_.stop_consuming(); }
virtual void stop_consuming() { cli_.stop_consuming(); }
/**
* Read the next message from the queue.
* This blocks until a new message arrives.
* @return The message and topic.
*/
const_message_ptr consume_message() { return cli_.consume_message(); }
virtual const_message_ptr consume_message() { return cli_.consume_message(); }
/**
* Try to read the next message from the queue without blocking.
* @param msg Pointer to the value to receive the message
* @return @em true is a message was read, @em false if no message was
* available.
*/
bool try_consume_message(const_message_ptr* msg) {
virtual bool try_consume_message(const_message_ptr* msg) {
return cli_.try_consume_message(msg);
}
/**

View File

@ -425,6 +425,31 @@ public:
virtual token_ptr unsubscribe(const string& topicFilter,
void* userContext, iaction_listener& cb,
const properties& props=properties()) =0;
/**
* Start consuming messages.
* This initializes the client to receive messages through a queue that
* can be read synchronously.
*/
virtual void start_consuming() =0;
/**
* Stop consuming messages.
* This shuts down the internal callback and discards any unread
* messages.
*/
virtual void stop_consuming() =0;
/**
* Read the next message from the queue.
* This blocks until a new message arrives.
* @return The message and topic.
*/
virtual const_message_ptr consume_message() =0;
/**
* Try to read the next message from the queue without blocking.
* @param msg Pointer to the value to receive the message
* @return @em true is a message was read, @em false if no message was
* available.
*/
virtual bool try_consume_message(const_message_ptr* msg) =0;
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -33,7 +33,7 @@ namespace mqtt {
/////////////////////////////////////////////////////////////////////////////
class mock_async_client : public mqtt::iasync_client
class mock_async_client : public virtual mqtt::iasync_client
{
public:
void remove_token(mqtt::token* tok) override {}
@ -209,6 +209,16 @@ public:
const properties& props=properties()) override {
return mqtt::token_ptr{};
}
void start_consuming() override {}
void stop_consuming() override {}
const_message_ptr consume_message() override {
return const_message_ptr{};
}
bool try_consume_message(const_message_ptr*) override { return false; }
};
/////////////////////////////////////////////////////////////////////////////