This commit is contained in:
aozhiwei 2019-09-17 17:32:40 +08:00
parent 45c356bbfa
commit 40a8f37ed6
3 changed files with 5 additions and 8 deletions

View File

@ -232,12 +232,9 @@ void GCListener::SetKey(int sockhandle, const std::string& key)
tcp_listener_->UnLockClients(); tcp_listener_->UnLockClients();
} }
void GCListener::InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg, int guess_size) void GCListener::InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg)
{ {
unsigned short packlen = 2 + CustomPbSerializeSize(&msg); unsigned short packlen = 2 + CustomPbSerializeSize(&msg);
if (guess_size > 0 && packlen - 2 < guess_size) {
packlen = guess_size + 2;
}
char* buff = (char*)malloc(sizeof(ServerPktHeader) + packlen); char* buff = (char*)malloc(sizeof(ServerPktHeader) + packlen);
memset(buff, 0, sizeof(ServerPktHeader) + packlen); memset(buff, 0, sizeof(ServerPktHeader) + packlen);
ServerPktHeader* head = (ServerPktHeader*)buff; ServerPktHeader* head = (ServerPktHeader*)buff;

View File

@ -33,11 +33,11 @@ class GCListener : public a8::Singleton<GCListener>
void UnInit(); void UnInit();
template <typename T> template <typename T>
void SendMsg(int socket_handle, T& msg, int guess_size = 0) void SendMsg(int socket_handle, T& msg)
{ {
static int msgid = f8::Net_GetMessageId(msg); static int msgid = f8::Net_GetMessageId(msg);
InternalSendMsg(socket_handle, msgid, msg, guess_size); InternalSendMsg(socket_handle, msgid, msg);
} }
void SendText(int sockhandle, const std::string& text); void SendText(int sockhandle, const std::string& text);
@ -47,7 +47,7 @@ class GCListener : public a8::Singleton<GCListener>
void SetKey(int sockhandle, const std::string& key); void SetKey(int sockhandle, const std::string& key);
private: private:
void InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg, int guess_size); void InternalSendMsg(int socket_handle, int msgid, google::protobuf::Message& msg);
private: private:
a8::TcpListener *tcp_listener_ = nullptr; a8::TcpListener *tcp_listener_ = nullptr;

View File

@ -83,7 +83,7 @@ void PlayerMgr::_CMCharEnum(f8::MsgHdr& hdr, const cs::CMCharEnum& msg)
DBEngine::Instance()->Next(); DBEngine::Instance()->Next();
} }
} }
GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg, 100); GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
} }
int PlayerMgr::OnlineNum() int PlayerMgr::OnlineNum()