From ccbacb5efde9828b864a8d79002621c9de75b15b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 3 Jun 2019 09:39:13 +0800 Subject: [PATCH] 1 --- server/robotserver/CMakeLists.txt | 2 +- server/robotserver/app.cc | 17 ++++++++++++++--- server/robotserver/virtualclient.cc | 28 ++++++++++++++++++++++------ server/robotserver/virtualclient.h | 3 +++ third_party/a8engine | 2 +- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/server/robotserver/CMakeLists.txt b/server/robotserver/CMakeLists.txt index 4812dbd..033e292 100644 --- a/server/robotserver/CMakeLists.txt +++ b/server/robotserver/CMakeLists.txt @@ -54,7 +54,7 @@ add_executable( add_custom_target(script_pb_protocol ALL) add_custom_command(TARGET script_pb_protocol 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) diff --git a/server/robotserver/app.cc b/server/robotserver/app.cc index fa6e569..6da18be 100755 --- a/server/robotserver/app.cc +++ b/server/robotserver/app.cc @@ -14,6 +14,7 @@ #include "app.h" #include "handlermgr.h" +#include "virtualclient.h" #include "virtualclientmgr.h" #include "ss_msgid.pb.h" @@ -360,11 +361,21 @@ void App::ProcessIMMsg() delete param; } break; + case IM_VirtualClientConnect: + { + VirtualClient* client = VirtualClientMgr::Instance()->GetVirtualClientByInstanceId( + pdelnode->params.sender + ); + if (client) { + client->SendJoin(); + } + } + break; case IM_VirtualClientDisconnect: { - #if 0 - PlayerMgr::Instance()->OnClientDisconnect(pdelnode->params); - #endif + VirtualClient* client = VirtualClientMgr::Instance()->GetVirtualClientByInstanceId( + pdelnode->params.sender + ); } break; case IM_ExecGM: diff --git a/server/robotserver/virtualclient.cc b/server/robotserver/virtualclient.cc index 4774122..a03f73c 100644 --- a/server/robotserver/virtualclient.cc +++ b/server/robotserver/virtualclient.cc @@ -6,6 +6,8 @@ #include "virtualclient.h" #include "app.h" +#include "ss_proto.pb.h" +#include "cs_proto.pb.h" 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) { 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; unsigned int offset = 0; - while (recv_bufflen_ - offset >= sizeof(f8::WSProxyPackHead_S)) { - f8::WSProxyPackHead_S* p = (f8::WSProxyPackHead_S*) &recv_buff_[offset]; + while (recv_bufflen_ - offset >= sizeof(f8::PackHead)) { + f8::PackHead* p = (f8::PackHead*) &recv_buff_[offset]; 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; } App::Instance()->AddSocketMsg(SF_VirtualClient, - p->socket_handle, instance_id, + 0, p->msgid, p->seqid, - &recv_buff_[offset + sizeof(f8::WSProxyPackHead_S)], + &recv_buff_[offset + sizeof(f8::PackHead)], p->packlen); - offset += sizeof(f8::WSProxyPackHead_S) + p->packlen; + offset += sizeof(f8::PackHead) + p->packlen; } else { warning = true; offset++; diff --git a/server/robotserver/virtualclient.h b/server/robotserver/virtualclient.h index df141cb..1567e46 100644 --- a/server/robotserver/virtualclient.h +++ b/server/robotserver/virtualclient.h @@ -27,7 +27,10 @@ class VirtualClient void SendMsg(T& msg) { static int msgid = f8::Net_GetMessageId(msg); + f8::Net_SendMsg(tcp_client_, 0, msgid, msg); } + void SendJoin(); + void SendMove(); private: void on_error(a8::TcpClient* sender, int errorId); diff --git a/third_party/a8engine b/third_party/a8engine index 3e1f116..8cee06b 160000 --- a/third_party/a8engine +++ b/third_party/a8engine @@ -1 +1 @@ -Subproject commit 3e1f116639d40a78e5ef625009685a611c5bf7bc +Subproject commit 8cee06b52896b0573eeff482a4c9fa1adac2a7fc