-
This is purely for debugging. size_t is unsigned, and -1 looks really weird in that case. As the default is DROP anyway, the value really doesn't matter.
-
Useful if you want to take action when a connection to the broker is established or lost. For example, after a reconnection you can expect to receive all retained messages again on the topics you are subscribed too.
-
This is a breaking API change. The whole interface of this library now uses "std::string_view" instead of "std::string" / "std::string &". In result, we can now promise to only copy data once thoughout the library. For subscriptions, this is a copy once to read the data from the socket into a buffer. For publish, this is a copy once to write the data in a buffer to send over the socket. For publish, this doesn't change the memory footprint, as because "std::string &" was already taking care of this. For subscriptions however, it reduces the memory usage by a factor of three. And as result it helps with the throughput.
-
This means the socket can be blocking, which makes administration easier. The drawback is that there is now a queue, including signalling, between the main thread and write thread. This consumes a bit more CPU; but in return the main thread is never blocked.
-
send() no longer is blocking, and all sendNNN calls now return false if the call couldn't be executed. Additionally, the library now recovers much better from issues, like unexpected broker disconnects.
-
This avoids copying the pointers from Client::Impl into Connection, which is just administrative work. Now we can access Client::Impl, and have all variables available to us.
-
Subscriptions are now stored in a tree-like structure, to quickly find the correct callbacks. This not only reduces the complexity from O(n) to O(logn), but also doesn't require stuff like regex. It does however require slightly more memory.
-
Just for small strings it will copy, and only large strings will actually be moved.
-
This includes CONNACK and SUBACK.
-
By using Happy Eyeballs, we stagger connections of a host resolves into multiple IPs. This is useful for IPv6 / IPv4 hosts, where one of the two can stutter. Sadly, creating a connection is rather complex, with many odd things that can happen along the way. For example, a writeable socket doesn't mean it is actually connected; it can also mean the socket is in an error state. This implementation is inspired by my own work on OpenTTD's variant of this.