create interface

This commit is contained in:
2023-11-29 11:53:20 +01:00
parent e8cb3ab9b9
commit 847393cec3
9 changed files with 148 additions and 1 deletions

View File

@@ -2,21 +2,26 @@
STOMPFrame::STOMPFrame(Command command, std::initializer_list<QPair<QString, QString>> headers, const QByteArray& body):
command_(command), body_(body) {
for (const auto& header: headers) {
headers_[header.first] = header.second;
}
}
qint64 STOMPFrame::send(QIODevice& device) {
QByteArray encoded;
QTextStream out {&encoded};
out << command_ << "\n";
for (const auto& key: headers_.keys()) {
out << key << ":" << headers_[key] << "\n";
}
if (!headers_.contains("content-length")) {
out << "content-length" << ":" << body_.size() << "\n";
}
out << "\n" << body_ << '\0';
out.flush();
return device.write(encoded);