This commit is contained in:
aozhiwei 2019-06-03 09:39:13 +08:00
parent d3bc4bba6a
commit ccbacb5efd
5 changed files with 41 additions and 11 deletions

View File

@ -54,7 +54,7 @@ add_executable(
add_custom_target(script_pb_protocol ALL) add_custom_target(script_pb_protocol ALL)
add_custom_command(TARGET script_pb_protocol add_custom_command(TARGET script_pb_protocol
PRE_BUILD PRE_BUILD
COMMAND python ../../third_party/tools/scripts/construct/build_pb.py --cpp_out=. --pb_files=ss_proto,ss_msgid COMMAND python ../../third_party/tools/scripts/construct/build_pb.py --cpp_out=. --pb_files=ss_proto,ss_msgid,cs_proto,cs_msgid
) )
add_dependencies(robotserver script_pb_protocol) add_dependencies(robotserver script_pb_protocol)

View File

@ -14,6 +14,7 @@
#include "app.h" #include "app.h"
#include "handlermgr.h" #include "handlermgr.h"
#include "virtualclient.h"
#include "virtualclientmgr.h" #include "virtualclientmgr.h"
#include "ss_msgid.pb.h" #include "ss_msgid.pb.h"
@ -360,11 +361,21 @@ void App::ProcessIMMsg()
delete param; delete param;
} }
break; break;
case IM_VirtualClientConnect:
{
VirtualClient* client = VirtualClientMgr::Instance()->GetVirtualClientByInstanceId(
pdelnode->params.sender
);
if (client) {
client->SendJoin();
}
}
break;
case IM_VirtualClientDisconnect: case IM_VirtualClientDisconnect:
{ {
#if 0 VirtualClient* client = VirtualClientMgr::Instance()->GetVirtualClientByInstanceId(
PlayerMgr::Instance()->OnClientDisconnect(pdelnode->params); pdelnode->params.sender
#endif );
} }
break; break;
case IM_ExecGM: case IM_ExecGM:

View File

@ -6,6 +6,8 @@
#include "virtualclient.h" #include "virtualclient.h"
#include "app.h" #include "app.h"
#include "ss_proto.pb.h"
#include "cs_proto.pb.h"
const int PACK_MAX = 1024 * 64; const int PACK_MAX = 1024 * 64;
@ -34,6 +36,20 @@ void VirtualClient::Update()
} }
void VirtualClient::SendJoin()
{
cs::CMJoin msg;
msg.set_server_id(2);
msg.set_account_id(account);
msg.set_baseskin(14001);
SendMsg(msg);
}
void VirtualClient::SendMove()
{
}
void VirtualClient::on_error(a8::TcpClient* sender, int errorId) void VirtualClient::on_error(a8::TcpClient* sender, int errorId)
{ {
a8::UdpLog::Instance()->Error("VirtualClient errorid=%d", {errorId}); a8::UdpLog::Instance()->Error("VirtualClient errorid=%d", {errorId});
@ -72,20 +88,20 @@ void VirtualClient::on_socketread(a8::TcpClient* sender, char* buf, unsigned int
bool warning = false; bool warning = false;
unsigned int offset = 0; unsigned int offset = 0;
while (recv_bufflen_ - offset >= sizeof(f8::WSProxyPackHead_S)) { while (recv_bufflen_ - offset >= sizeof(f8::PackHead)) {
f8::WSProxyPackHead_S* p = (f8::WSProxyPackHead_S*) &recv_buff_[offset]; f8::PackHead* p = (f8::PackHead*) &recv_buff_[offset];
if (p->magic_code == f8::MAGIC_CODE) { if (p->magic_code == f8::MAGIC_CODE) {
if (recv_bufflen_ - offset < sizeof(f8::WSProxyPackHead_S) + p->packlen) { if (recv_bufflen_ - offset < sizeof(f8::PackHead) + p->packlen) {
break; break;
} }
App::Instance()->AddSocketMsg(SF_VirtualClient, App::Instance()->AddSocketMsg(SF_VirtualClient,
p->socket_handle,
instance_id, instance_id,
0,
p->msgid, p->msgid,
p->seqid, p->seqid,
&recv_buff_[offset + sizeof(f8::WSProxyPackHead_S)], &recv_buff_[offset + sizeof(f8::PackHead)],
p->packlen); p->packlen);
offset += sizeof(f8::WSProxyPackHead_S) + p->packlen; offset += sizeof(f8::PackHead) + p->packlen;
} else { } else {
warning = true; warning = true;
offset++; offset++;

View File

@ -27,7 +27,10 @@ class VirtualClient
void SendMsg(T& msg) void SendMsg(T& msg)
{ {
static int msgid = f8::Net_GetMessageId(msg); static int msgid = f8::Net_GetMessageId(msg);
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
} }
void SendJoin();
void SendMove();
private: private:
void on_error(a8::TcpClient* sender, int errorId); void on_error(a8::TcpClient* sender, int errorId);

@ -1 +1 @@
Subproject commit 3e1f116639d40a78e5ef625009685a611c5bf7bc Subproject commit 8cee06b52896b0573eeff482a4c9fa1adac2a7fc