#pragma once #include #include #include #include #include #include class STOMPFrame { public: enum Command { INVALID, // Client messages STOMP, SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, COMMIT, ABORT, ACK, NACK, DISCONNECT, // Server messages CONNECTED, MESSAGE, RECEIPT, ERROR }; explicit STOMPFrame(Command command, std::initializer_list> headers = {}, const QByteArray& body = {}); bool isNull() const { return command_ == INVALID; } Command command() const { return command_; } void setCommand(Command command) { command_ = command; } const QMap& headers() const { return headers_; } void setHeaders(const QMap& headers) { headers_ = headers; } const QByteArray& body() const { return body_; } void setBody(const QByteArray& body) { body_ = body; } qint64 send(QIODevice& device); static STOMPFrame receive(QIODevice& device); private: STOMPFrame() = default; Command command_ = INVALID; QMap headers_; QByteArray body_; }; QTextStream& operator <<(QTextStream& out, STOMPFrame::Command command);