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