Commit c58b6f67 by 李维杰

add response

parent b0a69d11
...@@ -7,29 +7,51 @@ namespace offcn ...@@ -7,29 +7,51 @@ namespace offcn
{ {
"path": "join", "path": "join",
"rid" : "xxxid", "rid" : "xxxid",
"capacity" : "data" :
{ {
"pull_type" : "rtmp" "pull_type" : "null"
} }
} }
*/ */
std::string MqttRequest::JoinRequest(std::string local_id, std::string capacity) std::string MqttRequest::JoinRequest(std::string local_id)
{ {
return ""; Json::Value root;
Json::StreamWriterBuilder wBuilder;
root["path"] = "join";
root["rid"] = local_id;
Json::Value data;
data["pull_type"] = "null";
root["data"] = data;
return Json::writeString(wBuilder, root);
} }
/* /*
{ {
"path": "update", "path": "update",
"rid" : "xxxid", "rid" : "xxxid",
"capacity" : "data" :
{ {
"pull_type" : "kcp" "pull_type" : "rtmp" or "null" or "kcp"
} }
} }
*/ */
std::string MqttRequest::UpdateRequest(std::string local_id, std::string capacity) std::string MqttRequest::UpdateRequest(std::string local_id, std::string pull_type)
{ {
return ""; Json::Value root;
Json::StreamWriterBuilder wBuilder;
root["path"] = "update";
root["rid"] = local_id;
Json::Value data;
data["pull_type"] = pull_type;
root["data"] = data;
return Json::writeString(wBuilder, root);
} }
/* /*
{ {
...@@ -41,6 +63,35 @@ namespace offcn ...@@ -41,6 +63,35 @@ namespace offcn
*/ */
std::string MqttRequest::Candidate(std::string local_id, std::string remote_id, std::string type, std::string candidate) std::string MqttRequest::Candidate(std::string local_id, std::string remote_id, std::string type, std::string candidate)
{ {
return ""; Json::Value root;
Json::StreamWriterBuilder wBuilder;
root["path"] = type;
root["rid"] = local_id;
root["tid"] = remote_id;
root["candidate"] = candidate;
return Json::writeString(wBuilder, root);
}
std::string MqttRequest::JoinResponse(std::string ids, std::string result)
{
Json::Value root;
Json::StreamWriterBuilder wBuilder;
root["path"] = "join";
root["result"] = result;
return Json::writeString(wBuilder, root);
}
std::string MqttRequest::UpdateResponse(std::string result)
{
Json::Value root;
Json::StreamWriterBuilder wBuilder;
root["path"] = "update";
root["result"] = result;
return Json::writeString(wBuilder, root);
} }
} }
\ No newline at end of file
...@@ -7,8 +7,12 @@ namespace offcn ...@@ -7,8 +7,12 @@ namespace offcn
class MqttRequest class MqttRequest
{ {
public: public:
static std::string JoinRequest(std::string local_id, std::string capacity); static std::string JoinRequest(std::string local_id);
static std::string UpdateRequest(std::string local_id, std::string capacity); static std::string UpdateRequest(std::string local_id, std::string pull_type);
static std::string Candidate(std::string local_id, std::string remote_id, std::string type, std::string candidate); static std::string Candidate(std::string local_id, std::string remote_id, std::string type, std::string candidate);
static std::string JoinResponse(std::string ids, std::string result);
static std::string UpdateResponse(std::string result);
}; };
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment