1 parent
01362d2e51
commit
39aff68d8d
29 files changed
+2061
-1818
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#include "echoion/core/state/StateSerializer.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
Echoion::Core::StateV1 state;
|
||||
state.extensionPlugins.push_back({.name = "example", .json = "{\"v\":1}",
|
||||
.version = 3});
|
||||
|
||||
auto blob = Echoion::Core::StateSerializer::serialize(state);
|
||||
std::string json{blob.data.begin(), blob.data.end()};
|
||||
// State written by the removed experimental rooms build must remain safe to
|
||||
// load during a hot reload. Void reflection intentionally ignores unknown
|
||||
// root fields, so the obsolete payload is discarded rather than rejected.
|
||||
json.insert(json.rfind('}'),
|
||||
R"(,"listeningRooms":[{"name":"legacy","subscribers":["uid"]}])");
|
||||
blob.data.assign(json.begin(), json.end());
|
||||
|
||||
const auto restored = Echoion::Core::StateSerializer::deserialize(blob);
|
||||
if (!restored) {
|
||||
std::cerr << "extension state did not deserialize: "
|
||||
<< restored.error().message << '\n';
|
||||
return 1;
|
||||
}
|
||||
if (restored->extensionPlugins.size() != 1 ||
|
||||
restored->extensionPlugins.front().name != "example" ||
|
||||
restored->extensionPlugins.front().version != 3) {
|
||||
std::cerr << "extension plugin state did not round-trip\n";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user