Change: [Network] Transfer command data as serialized byte stream without fixed structure.

The data will be transmitted as the length followed by the serialized data. This allows the command
data to be different for every command type in the future.
This commit is contained in:
Michael Lutz
2021-10-28 23:48:26 +02:00
parent b0990fcff7
commit a05fd7aa50
15 changed files with 455 additions and 35 deletions

View File

@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <ctype.h> /* required for tolower() */
#include <sstream>
#include <iomanip>
#ifdef _MSC_VER
#include <errno.h> // required by vsnprintf implementation for MSVC
@@ -160,6 +161,23 @@ char *CDECL str_fmt(const char *str, ...)
return p;
}
/**
* Format a byte array into a continuous hex string.
* @param data Array to format
* @return Converted string.
*/
std::string FormatArrayAsHex(span<const byte> data)
{
std::ostringstream ss;
ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex;
for (auto b : data) {
ss << b;
}
return ss.str();
}
/**
* Scan the string for old values of SCC_ENCODED and fix it to
* it's new, static value.