Update relayreg.cpp — serialize displays JSON array in registerHost
This commit is contained in:
parent
5f9661605c
commit
ece712ec61
1 changed files with 22 additions and 2 deletions
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wg {
|
||||
|
||||
|
|
@ -151,8 +152,27 @@ bool RelayReg::deleteVPNPeer(const std::string &peerId, std::string &errOut) {
|
|||
// ── registerHost ──────────────────────────────────────────────────────────────
|
||||
|
||||
bool RelayReg::registerHost(const std::string &name, const std::string &wgIP,
|
||||
int port, std::string &errOut) {
|
||||
json body = { {"name", name}, {"wg_ip", wgIP}, {"port", port} };
|
||||
int port, const std::vector<DisplayInfo> &displays,
|
||||
std::string &errOut) {
|
||||
// Build displays JSON array
|
||||
json displaysArr = json::array();
|
||||
for (const auto &d : displays) {
|
||||
displaysArr.push_back({
|
||||
{"name", d.name},
|
||||
{"friendlyName", d.friendlyName},
|
||||
{"width", d.width},
|
||||
{"height", d.height},
|
||||
{"isPrimary", d.isPrimary}
|
||||
});
|
||||
}
|
||||
|
||||
json body = {
|
||||
{"name", name},
|
||||
{"wg_ip", wgIP},
|
||||
{"port", port},
|
||||
{"displays", displaysArr}
|
||||
};
|
||||
|
||||
std::string resp;
|
||||
int code = request("POST", "/api/host/register", body.dump(), resp);
|
||||
if (code != 200 && code != 201) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue