|
@@ -11,6 +11,9 @@ namespace gsd{
|
|
|
}
|
|
|
|
|
|
int32_t Hepu::Init(std::string username, std::string url, int port){
|
|
|
+ cout<<"Hepu username: "<<username<<endl;
|
|
|
+ cout<<"Hepu api url: "<<url<<endl;
|
|
|
+ cout<<"Hepu port: "<<port<<endl;
|
|
|
this->username_ = username;
|
|
|
m_hepu = std::make_shared<httplib::Client>(url, port);
|
|
|
if(m_hepu == NULL){
|
|
@@ -48,19 +51,24 @@ namespace gsd{
|
|
|
hepuloginMsg.objectToJson(msg);
|
|
|
msg += "\r\n";
|
|
|
|
|
|
- //cout<<msg<<endl;
|
|
|
+ cout<<"login json msg: "<<endl;
|
|
|
+ cout<<msg<<endl;
|
|
|
|
|
|
if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
|
|
|
+ cout<<res->body<<endl;
|
|
|
if(res->status != 100){
|
|
|
HepuLoginRe hepuloginReMsg;
|
|
|
if(!hepuloginReMsg.jsonToObject(res->body)){
|
|
|
+ cout<<"login res json2object fail."<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
if(hepuloginReMsg.ackvalue != 100){
|
|
|
+ cout<<"login res ack err: "<<hepuloginReMsg.ackvalue<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
if(hepuloginReMsg.token.size()){
|
|
|
this->token_ = hepuloginReMsg.token;
|
|
|
+ cout<<"login res token: "<<hepuloginReMsg.token<<endl;
|
|
|
return OK;
|
|
|
}
|
|
|
return ERR;
|
|
@@ -68,6 +76,7 @@ namespace gsd{
|
|
|
return ERR;
|
|
|
}else{
|
|
|
auto err = res.error();
|
|
|
+ cout<<"The Hepu is not avaliable, "<<err<<endl;
|
|
|
ErrorL << "The service is not available,"<<err<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
@@ -86,15 +95,19 @@ namespace gsd{
|
|
|
hepuHBMsg.objectToJson(msg);
|
|
|
msg+="\r\n";
|
|
|
|
|
|
- //cout<<msg<<endl;
|
|
|
+ cout<<"hb json msg: "<<endl;
|
|
|
+ cout<<msg<<endl;
|
|
|
|
|
|
if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
|
|
|
+ cout<<res->body<<endl;
|
|
|
if(res->status != 100){
|
|
|
HepuHBRe hepuHBReMsg;
|
|
|
if(!hepuHBReMsg.jsonToObject(res->body)){
|
|
|
+ cout<<"hb res json2object fail."<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
if(hepuHBReMsg.ackvalue != 100){
|
|
|
+ cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
return OK;
|
|
@@ -102,6 +115,7 @@ namespace gsd{
|
|
|
return ERR;
|
|
|
}else{
|
|
|
auto err = res.error();
|
|
|
+ cout<<"Hepu heartbeat failed,"<<err<<endl;
|
|
|
ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
@@ -117,15 +131,19 @@ namespace gsd{
|
|
|
hepuHBMsg.objectToJson(msg);
|
|
|
msg+="\r\n";
|
|
|
|
|
|
- //cout<<msg<<endl;
|
|
|
+ cout<<"hb json msg: "<<endl;
|
|
|
+ cout<<msg<<endl;
|
|
|
|
|
|
if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
|
|
|
+ cout<<res->body<<endl;
|
|
|
if(res->status != 100){
|
|
|
HepuHBRe hepuHBReMsg;
|
|
|
if(!hepuHBReMsg.jsonToObject(res->body)){
|
|
|
+ cout<<"hb res json2object fail."<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
if(hepuHBReMsg.ackvalue != 100){
|
|
|
+ cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
return OK;
|
|
@@ -133,6 +151,7 @@ namespace gsd{
|
|
|
return ERR;
|
|
|
}else{
|
|
|
auto err = res.error();
|
|
|
+ cout<<"Hepu heartbeat failed,"<<err<<endl;
|
|
|
ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
@@ -150,15 +169,19 @@ namespace gsd{
|
|
|
HepuTargetMsg.objectToJson(msg);
|
|
|
msg+="\r\n";
|
|
|
|
|
|
- //cout<<msg<<endl;
|
|
|
+ cout<<"Target json msg: "<<endl;
|
|
|
+ cout<<msg<<endl;
|
|
|
|
|
|
if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
|
|
|
+ cout<<res->body<<endl;
|
|
|
if(res->status != 100){
|
|
|
HepuTargetRe hepuTargetReMsg;
|
|
|
if(!hepuTargetReMsg.jsonToObject(res->body)){
|
|
|
+ cout<<"target res json2object fail."<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
if(hepuTargetReMsg.ackvalue != 100){
|
|
|
+ cout<<"hb res ack err: "<<hepuTargetReMsg.ackvalue<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
return OK;
|
|
@@ -166,7 +189,8 @@ namespace gsd{
|
|
|
return ERR;
|
|
|
}else{
|
|
|
auto err = res.error();
|
|
|
- ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
|
|
|
+ cout<<"Hepu send target failed,"<<err<<endl;
|
|
|
+ ErrorL << "Hepu send target failed,"<<err<<endl;
|
|
|
return ERR;
|
|
|
}
|
|
|
return ERR;
|