登录指令成功收到响应

This commit is contained in:
大石头 2017-08-26 20:21:22 +08:00
parent 3005367c4b
commit 22a1931e35
3 changed files with 10 additions and 9 deletions

View File

@ -198,10 +198,11 @@ void LinkClient::OnReceive(LinkMessage& msg)
}
bool LinkClient::Send(const LinkMessage& msg) {
return Master->Send(msg.GetString());
return Master->Send(msg.GetBuffer());
}
bool LinkClient::Invoke(const String& action, const String& args) {
bool LinkClient::Invoke(const String& action, const Json& args) {
// 消息缓冲区,跳过头部
char cs[512];
/*String str(&cs[sizeof(LinkMessage)], sizeof(cs) - sizeof(LinkMessage), false);
@ -249,7 +250,7 @@ void LinkClient::Login()
Json json;
json.Add("User", User);
json.Add("user", User);
// 原始密码对盐值进行加密,得到登录密码
auto now = DateTime::Now().TotalMs();
@ -261,9 +262,9 @@ void LinkClient::Login()
auto pass = bs.ToHex();
pass += arr.ToHex();
json.Add("Password", pass);
json.Add("pass", pass);
Invoke("Login", json.ToString());
Invoke("Device/Login", json);
}
void LinkClient::OnLogin(LinkMessage& msg)
@ -317,8 +318,7 @@ void LinkClient::Ping()
// 30秒内发过数据不再发送心跳
if (LastSend > 0 && LastSend + 60000 > Sys.Ms()) return;
String args;
Json json(args);
Json json;
//json.Add("Data", Store.Data.ToHex());
@ -326,7 +326,7 @@ void LinkClient::Ping()
auto ms = (int)Sys.Ms();
json.Add("Time", ms);
Invoke("Ping", args);
Invoke("Device/Ping", json);
}
void LinkClient::OnPing(LinkMessage& msg)

View File

@ -35,7 +35,7 @@ public:
void Close();
// 发送消息
bool Invoke(const String& action, const String& args);
bool Invoke(const String& action, const Json& args);
bool Reply(String& action, int code, String& result, int seq);
// 收到功能消息时触发

View File

@ -18,6 +18,7 @@ public:
// 数据指针
const void* Data() const { return (const void*)&this[1]; }
const Buffer GetBuffer() const { return Buffer((void*)this, sizeof(this[0]) + Length); }
const String GetString() const { return String((cstring)&this[1], Length); }
void Init();