|
@@ -11,7 +11,7 @@ namespace gsd{
|
|
|
}
|
|
|
|
|
|
int32_t Hepu::Init(std::string username, std::string url, int port){
|
|
|
- this->username = username;
|
|
|
+ this->username_ = username;
|
|
|
m_hepu = std::make_shared<httplib::Client>(url, port);
|
|
|
if(m_hepu == NULL){
|
|
|
ErrorL << "Hepu http client initialization failed.";
|
|
@@ -24,14 +24,27 @@ namespace gsd{
|
|
|
return OK;
|
|
|
}
|
|
|
|
|
|
+ int32_t Hepu::Init2(){
|
|
|
+ m_hepu = std::make_shared<httplib::Client>(this->url_, this->port_);
|
|
|
+ if(m_hepu == NULL){
|
|
|
+ ErrorL << "Hepu http client initialization failed.";
|
|
|
+ return ERR;
|
|
|
+ }
|
|
|
+ if(this->LoginHepu() != OK){
|
|
|
+ ErrorL << "Failed to login to Hepu IPC.";
|
|
|
+ return ERR;
|
|
|
+ }
|
|
|
+ return OK;
|
|
|
+ }
|
|
|
+
|
|
|
int32_t Hepu::LoginHepu(){
|
|
|
if(m_hepu == nullptr) return ERR;
|
|
|
|
|
|
HepuLogin hepuloginMsg;
|
|
|
std::string msg;
|
|
|
hepuloginMsg.token = "";
|
|
|
- hepuloginMsg.username = this->username;
|
|
|
- hepuloginMsg.password = this->password;
|
|
|
+ hepuloginMsg.username = this->username_;
|
|
|
+ hepuloginMsg.password = this->password_;
|
|
|
hepuloginMsg.objectToJson(msg);
|
|
|
msg += "\r\n";
|
|
|
|
|
@@ -47,7 +60,7 @@ namespace gsd{
|
|
|
return ERR;
|
|
|
}
|
|
|
if(hepuloginReMsg.token.size()){
|
|
|
- this->token = hepuloginReMsg.token;
|
|
|
+ this->token_ = hepuloginReMsg.token;
|
|
|
return OK;
|
|
|
}
|
|
|
return ERR;
|
|
@@ -62,14 +75,14 @@ namespace gsd{
|
|
|
}
|
|
|
|
|
|
bool Hepu::alive(){
|
|
|
- return this->token == "" ? false : true;
|
|
|
+ return this->token_ == "" ? false : true;
|
|
|
}
|
|
|
|
|
|
int32_t Hepu::sendHepuHB(HepuHB& hepuHBMsg){
|
|
|
if(m_hepu == nullptr) return ERR;
|
|
|
|
|
|
std::string msg;
|
|
|
- hepuHBMsg.token = this->token;
|
|
|
+ hepuHBMsg.token = this->token_;
|
|
|
hepuHBMsg.objectToJson(msg);
|
|
|
msg+="\r\n";
|
|
|
|
|
@@ -100,7 +113,7 @@ namespace gsd{
|
|
|
|
|
|
HepuHB hepuHBMsg;
|
|
|
std::string msg;
|
|
|
- hepuHBMsg.token = this->token;
|
|
|
+ hepuHBMsg.token = this->token_;
|
|
|
hepuHBMsg.objectToJson(msg);
|
|
|
msg+="\r\n";
|
|
|
|
|
@@ -130,7 +143,7 @@ namespace gsd{
|
|
|
if(m_hepu == nullptr) return ERR;
|
|
|
|
|
|
std::string msg;
|
|
|
- HepuTargetMsg.token = this->token;
|
|
|
+ HepuTargetMsg.token = this->token_;
|
|
|
HepuTargetMsg.channelid = 1;
|
|
|
HepuTargetMsg.bTracking = true;
|
|
|
HepuTargetMsg.trackingTime = 0;
|
|
@@ -158,4 +171,25 @@ namespace gsd{
|
|
|
}
|
|
|
return ERR;
|
|
|
}
|
|
|
+
|
|
|
+ void Hepu::setUsr(string username)
|
|
|
+ {
|
|
|
+ this->username_ = username;
|
|
|
+ }
|
|
|
+
|
|
|
+ void Hepu::setPwd(string password)
|
|
|
+ {
|
|
|
+ this->password_ = password;
|
|
|
+ }
|
|
|
+
|
|
|
+ void Hepu::setUrl(string url)
|
|
|
+ {
|
|
|
+ this->url_ = url;
|
|
|
+ }
|
|
|
+
|
|
|
+ void Hepu::setPort(int port)
|
|
|
+ {
|
|
|
+ this->port_ = port;
|
|
|
+ }
|
|
|
+
|
|
|
}
|