Skip to content

Commit 667f8cd

Browse files
authored
Merge pull request #944 from redboltz/add_clear_user_pass
Added clear username and password functionality.
2 parents 0d9155d + 99df0b8 commit 667f8cd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/mqtt/client.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,17 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
921921
user_name_ = force_move(name);
922922
}
923923

924+
/**
925+
* @brief Clear username.
926+
*
927+
* This function should be called before calling connect().<BR>
928+
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071<BR>
929+
* 3.1.3.5 User Name
930+
*/
931+
void set_user_name() {
932+
user_name_ = nullopt;
933+
}
934+
924935
/**
925936
* @brief Set password.
926937
* @param password password
@@ -933,6 +944,17 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
933944
password_ = force_move(password);
934945
}
935946

947+
/**
948+
* @brief Clear password.
949+
*
950+
* This function should be called before calling connect().<BR>
951+
* See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072<BR>
952+
* 3.1.3.6 Password
953+
*/
954+
void set_password() {
955+
password_ = nullopt;
956+
}
957+
936958
/**
937959
* @brief Set will.
938960
* @param w will

0 commit comments

Comments
 (0)