提交 cb065ca6 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Refactor TransportTuple json output

上级 dc10297f
......@@ -13,39 +13,30 @@ namespace RTC
{
MS_TRACE();
static const Json::StaticString k_local("local");
static const Json::StaticString k_remote("remote");
static const Json::StaticString k_ip("ip");
static const Json::StaticString k_port("port");
static const Json::StaticString k_localIP("localIP");
static const Json::StaticString k_remoteIP("remoteIP");
static const Json::StaticString k_localPort("localPort");
static const Json::StaticString k_remotePort("remotePort");
static const Json::StaticString k_protocol("protocol");
static const Json::StaticString v_udp("udp");
static const Json::StaticString v_tcp("tcp");
Json::Value json(Json::objectValue);
Json::Value json_local(Json::objectValue);
Json::Value json_remote(Json::objectValue);
int ip_family;
std::string ip;
uint16_t port;
Utils::IP::GetAddressInfo(this->GetLocalAddress(), &ip_family, ip, &port);
json_local[k_ip] = ip;
json_local[k_port] = (Json::UInt)port;
json[k_localIP] = ip;
json[k_localPort] = (Json::UInt)port;
if (this->GetProtocol() == RTC::TransportTuple::Protocol::UDP)
json_local[k_protocol] = v_udp;
json[k_protocol] = v_udp;
else
json_local[k_protocol] = v_tcp;
json[k_protocol] = v_tcp;
Utils::IP::GetAddressInfo(this->GetRemoteAddress(), &ip_family, ip, &port);
json_remote[k_ip] = ip;
json_remote[k_port] = (Json::UInt)port;
if (this->GetProtocol() == RTC::TransportTuple::Protocol::UDP)
json_remote[k_protocol] = v_udp;
else
json_remote[k_protocol] = v_tcp;
json[k_local] = json_local;
json[k_remote] = json_remote;
json[k_remoteIP] = ip;
json[k_remotePort] = (Json::UInt)port;
return json;
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论