mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
webrtc: Refactor {to,from}JSON() to {to,from}Json()
Signed-off-by: Steffen Vogel <steffen.vogel@opal-rt.com>
This commit is contained in:
parent
294af6aaca
commit
31eabd7b9d
3 changed files with 13 additions and 13 deletions
|
@ -32,7 +32,7 @@ struct Peer {
|
|||
std::chrono::time_point<std::chrono::system_clock> created;
|
||||
|
||||
Peer(json_t *j);
|
||||
json_t * toJSON() const;
|
||||
json_t * toJson() const;
|
||||
};
|
||||
|
||||
struct RelayMessage {
|
||||
|
@ -46,14 +46,14 @@ struct ControlMessage {
|
|||
std::vector<Peer> peers;
|
||||
|
||||
ControlMessage(json_t *j);
|
||||
json_t * toJSON() const;
|
||||
json_t * toJson() const;
|
||||
};
|
||||
|
||||
struct SignalingMessage {
|
||||
std::variant<std::monostate, RelayMessage, ControlMessage, SignalList, rtc::Description, rtc::Candidate> message;
|
||||
|
||||
static SignalingMessage fromJSON(json_t *j);
|
||||
json_t * toJSON() const;
|
||||
static SignalingMessage fromJson(json_t *j);
|
||||
json_t * toJson() const;
|
||||
std::string toString() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ int SignalingClient::protocolCallback(struct lws *wsi, enum lws_callback_reasons
|
|||
goto do_retry;
|
||||
}
|
||||
|
||||
cbMessage(SignalingMessage::fromJSON(json));
|
||||
cbMessage(SignalingMessage::fromJson(json));
|
||||
|
||||
json_decref(json);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ int SignalingClient::writable()
|
|||
}
|
||||
|
||||
auto msg = outgoingMessages.pop();
|
||||
auto *jsonMsg = msg.toJSON();
|
||||
auto *jsonMsg = msg.toJson();
|
||||
|
||||
if (!jsonMsg) {
|
||||
return 0;
|
||||
|
|
|
@ -17,7 +17,7 @@ using namespace villas;
|
|||
using namespace villas::node;
|
||||
using namespace villas::node::webrtc;
|
||||
|
||||
json_t * Peer::toJSON() const
|
||||
json_t * Peer::toJson() const
|
||||
{
|
||||
return json_pack("{ s:i, s:s*, s:s*, s:s* }",
|
||||
"id", id,
|
||||
|
@ -89,12 +89,12 @@ RelayMessage::RelayMessage(json_t *json)
|
|||
}
|
||||
}
|
||||
|
||||
json_t * ControlMessage::toJSON() const
|
||||
json_t * ControlMessage::toJson() const
|
||||
{
|
||||
json_t *json_peers = json_array();
|
||||
|
||||
for (auto &p : peers) {
|
||||
json_t *json_peer = p.toJSON();
|
||||
json_t *json_peer = p.toJson();
|
||||
|
||||
json_array_append_new(json_peers, json_peer);
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ ControlMessage::ControlMessage(json_t *j)
|
|||
peers.emplace_back(json_peer);
|
||||
}
|
||||
|
||||
json_t * SignalingMessage::toJSON() const
|
||||
json_t * SignalingMessage::toJson() const
|
||||
{
|
||||
return std::visit(villas::utils::overloaded {
|
||||
[](ControlMessage const &c){
|
||||
return json_pack("{ s:o }", "control", c.toJSON());
|
||||
return json_pack("{ s:o }", "control", c.toJson());
|
||||
},
|
||||
[](SignalList const &s){
|
||||
return json_pack("{ s:o }", "signals", s.toJson());
|
||||
|
@ -162,7 +162,7 @@ std::string SignalingMessage::toString() const
|
|||
return fmt::format("type=relay");
|
||||
},
|
||||
[](ControlMessage const &c){
|
||||
return fmt::format("type=control, control={}", json_dumps(c.toJSON(), 0));
|
||||
return fmt::format("type=control, control={}", json_dumps(c.toJson(), 0));
|
||||
},
|
||||
[](SignalList const &s){
|
||||
return fmt::format("type=signal");
|
||||
|
@ -179,7 +179,7 @@ std::string SignalingMessage::toString() const
|
|||
}, message);
|
||||
}
|
||||
|
||||
SignalingMessage SignalingMessage::fromJSON(json_t *json)
|
||||
SignalingMessage SignalingMessage::fromJson(json_t *json)
|
||||
{
|
||||
auto self = SignalingMessage { std::monostate() };
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue