diff options
| author | Linus Jahn <lnj@kaidan.im> | 2021-09-03 18:17:40 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-09-03 20:42:34 +0200 |
| commit | 040b7d9a8c7625f93e93690e47dbabb71ff87fd7 (patch) | |
| tree | 15a2ad8b8b13c6beeb38c6438953b896992f699e /src/base/QXmppSendResult.h | |
| parent | 0623aa38f2ead734dddea4cbad899a868f01cb1e (diff) | |
| download | qxmpp-040b7d9a8c7625f93e93690e47dbabb71ff87fd7.tar.gz | |
Refactor packet sending: Add SendSuccess/SendError
Diffstat (limited to 'src/base/QXmppSendResult.h')
| -rw-r--r-- | src/base/QXmppSendResult.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/base/QXmppSendResult.h b/src/base/QXmppSendResult.h new file mode 100644 index 00000000..15b84b05 --- /dev/null +++ b/src/base/QXmppSendResult.h @@ -0,0 +1,48 @@ +#ifndef QXMPPSENDRESULT_H +#define QXMPPSENDRESULT_H + +#include "QXmppGlobal.h" + +#include <variant> + +namespace QXmpp { + +/// +/// A struct containing a packet send error type and error message. +/// +/// \since QXmpp 1.5 +/// +struct SendError +{ + /// Describes the type of an error. + enum Type : uint8_t { + SocketWriteError, ///< The packet was written to the socket with no success (only happens when Stream Management is disabled). + Disconnected, ///< The packet couldn't be sent because the connection hasn't been (re)established. + EncryptionError, ///< The packet couldn't be sent because prior encryption failed. + }; + + /// Text describing the error. + QString text; + /// Type of the occured error. + Type type; +}; + +/// +/// A struct indicating success when sending packets +/// +/// \since QXmpp 1.5 +/// +struct SendSuccess +{ + /// Indicates whether the packet has been acknowledged by the other peer. + bool acknowledged = false; +}; + +/// +/// A variant containing either a SendSuccess object or a SendError. +/// +using SendResult = std::variant<SendSuccess, SendError>; + +} + +#endif // QXMPPSENDRESULT_H |
