Commit 3893af5d56aea6360353f74d3554bd7160057f96
1 parent
de90ee61
Show MQTT version in client string
Showing
3 changed files
with
20 additions
and
2 deletions
client.cpp
| @@ -277,9 +277,9 @@ bool Client::writeBufIntoFd() | @@ -277,9 +277,9 @@ bool Client::writeBufIntoFd() | ||
| 277 | 277 | ||
| 278 | std::string Client::repr() | 278 | std::string Client::repr() |
| 279 | { | 279 | { |
| 280 | - std::string s = formatString("[ClientID='%s', username='%s', fd=%d, keepalive=%ds, transport='%s', address='%s', cleanses=%d]", | 280 | + std::string s = formatString("[ClientID='%s', username='%s', fd=%d, keepalive=%ds, transport='%s', address='%s', cleanses=%d, prot=%s]", |
| 281 | clientid.c_str(), username.c_str(), fd, keepalive, this->transportStr.c_str(), this->address.c_str(), | 281 | clientid.c_str(), username.c_str(), fd, keepalive, this->transportStr.c_str(), this->address.c_str(), |
| 282 | - cleanSession); | 282 | + cleanSession, protocolVersionString(protocolVersion).c_str()); |
| 283 | return s; | 283 | return s; |
| 284 | } | 284 | } |
| 285 | 285 |
utils.cpp
| @@ -651,3 +651,18 @@ const std::string websocketCloseCodeToString(uint16_t code) | @@ -651,3 +651,18 @@ const std::string websocketCloseCodeToString(uint16_t code) | ||
| 651 | return formatString("Websocket status code %d", code); | 651 | return formatString("Websocket status code %d", code); |
| 652 | } | 652 | } |
| 653 | } | 653 | } |
| 654 | + | ||
| 655 | +const std::string protocolVersionString(ProtocolVersion p) | ||
| 656 | +{ | ||
| 657 | + switch (p) | ||
| 658 | + { | ||
| 659 | + case ProtocolVersion::None: | ||
| 660 | + return "none"; | ||
| 661 | + case ProtocolVersion::Mqtt31: | ||
| 662 | + return "3.1"; | ||
| 663 | + case ProtocolVersion::Mqtt311: | ||
| 664 | + return "3.1.1"; | ||
| 665 | + default: | ||
| 666 | + return "unknown"; | ||
| 667 | + } | ||
| 668 | +} |
utils.h
| @@ -33,6 +33,7 @@ License along with FlashMQ. If not, see <https://www.gnu.org/licenses/>. | @@ -33,6 +33,7 @@ License along with FlashMQ. If not, see <https://www.gnu.org/licenses/>. | ||
| 33 | 33 | ||
| 34 | #include "cirbuf.h" | 34 | #include "cirbuf.h" |
| 35 | #include "bindaddr.h" | 35 | #include "bindaddr.h" |
| 36 | +#include "types.h" | ||
| 36 | 37 | ||
| 37 | template<typename T> int check(int rc) | 38 | template<typename T> int check(int rc) |
| 38 | { | 39 | { |
| @@ -124,5 +125,7 @@ template<typename ex> void checkWritableDir(const std::string &path) | @@ -124,5 +125,7 @@ template<typename ex> void checkWritableDir(const std::string &path) | ||
| 124 | 125 | ||
| 125 | const std::string websocketCloseCodeToString(uint16_t code); | 126 | const std::string websocketCloseCodeToString(uint16_t code); |
| 126 | 127 | ||
| 128 | +const std::string protocolVersionString(ProtocolVersion p); | ||
| 129 | + | ||
| 127 | 130 | ||
| 128 | #endif // UTILS_H | 131 | #endif // UTILS_H |