客户端增加Invoke

This commit is contained in:
nnhy 2016-05-12 07:55:58 +00:00
parent 5eb8a5e480
commit a93d9c0871
2 changed files with 33 additions and 2 deletions

View File

@ -117,6 +117,9 @@ bool TokenClient::OnReceive(TokenMessage& msg, Controller* ctrl)
case 0x07:
OnRegister(msg, ctrl);
break;
case 0x08:
OnInvoke(msg, ctrl);
break;
}
// 消息转发
@ -399,7 +402,7 @@ void TokenClient::Login(TokenMessage& msg, Controller* ctrl)
TS("TokenClient::Login2");
auto rs = msg.CreateReply();
LoginMessage login;
// 这里需要随机密匙
//login.Key = Key.Copy(Sys.ID, 16);
@ -540,3 +543,22 @@ bool TokenClient::ChangeIPEndPoint(const String& domain, ushort port)
return true;
}
void TokenClient::Invoke(const String& action, Buffer& bs)
{
TokenMessage msg;
auto ms = msg.ToStream();
BinaryPair bp(ms);
bp.Set("Action", action);
ms.Write(bs);
Control->Send(msg);
}
void TokenClient::OnInvoke(TokenMessage& msg, Controller* ctrl)
{
}

View File

@ -58,7 +58,7 @@ public:
void Register();
void OnRegister(TokenMessage& msg, Controller* ctrl);
// 登录
void Login();
void Login();
void Login(TokenMessage& msg,Controller* ctrl);
bool OnLogin(TokenMessage& msg, Controller* ctrl);
@ -66,6 +66,15 @@ public:
void Ping();
bool OnPing(TokenMessage& msg, Controller* ctrl);
bool ChangeIPEndPoint(const String& domain, ushort port);
void Read();
void OnRead(TokenMessage& msg, Controller* ctrl);
void Write();
void OnWrite(TokenMessage& msg, Controller* ctrl);
// 远程调用
void Invoke(const String& action, Buffer& bs);
void OnInvoke(TokenMessage& msg, Controller* ctrl);
};
// 令牌会话