Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
527708e6c2 | ||
![]() |
e00585eb27 | ||
![]() |
d0cc5c02c2 | ||
![]() |
2b6880d46b | ||
![]() |
acb71d7e62 |
@ -19,6 +19,7 @@ message SS_CMLogin
|
||||
optional string team_uuid = 2; //保留
|
||||
optional string account_id = 3; //账号id
|
||||
optional int32 proto_version = 5; //协议版本号Constant_e.ProtoVersion
|
||||
optional string session_id = 20; //session_id
|
||||
}
|
||||
|
||||
message SS_CMReconnect
|
||||
@ -39,6 +40,9 @@ message SS_WSP_RequestTargetServer
|
||||
optional string server_info = 4;
|
||||
optional int32 is_reconnect = 5;
|
||||
optional int32 proto_version = 6; //协议版本号Constant_e.ProtoVersion
|
||||
optional string url = 7;
|
||||
optional string query_str = 8;
|
||||
optional string session_id = 9;
|
||||
}
|
||||
|
||||
message SS_MS_ResponseTargetServer
|
||||
|
@ -42,6 +42,8 @@ include_directories(
|
||||
/usr/include/glm
|
||||
../../third_party
|
||||
../../third_party/behaviac/inc
|
||||
../../third_party/recastnavigation/Recast/Include
|
||||
../../third_party/recastnavigation/Detour/Include
|
||||
../../third_party/recastnavigation/Detour/Include
|
||||
../../third_party/recastnavigation/DetourTileCache/Include
|
||||
.
|
||||
@ -61,6 +63,14 @@ aux_source_directory(../../third_party/framework/cpp
|
||||
SRC_LIST
|
||||
)
|
||||
|
||||
aux_source_directory(../../third_party/recastnavigation/Recast/Source
|
||||
SRC_LIST
|
||||
)
|
||||
|
||||
aux_source_directory(../../third_party/recastnavigation/RecastDemo/Contrib/fastlz
|
||||
SRC_LIST
|
||||
)
|
||||
|
||||
aux_source_directory(../../third_party/recastnavigation/Detour/Source
|
||||
SRC_LIST
|
||||
)
|
||||
|
@ -5,12 +5,18 @@
|
||||
#include <a8/tcplistener.h>
|
||||
|
||||
#include "framework/cpp/netmsghandler.h"
|
||||
#include "framework/cpp/im_msgid.pb.h"
|
||||
#include "framework/cpp/im_proto.pb.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "GCListener.h"
|
||||
#include "jsondatamgr.h"
|
||||
#include "ss_proto.pb.h"
|
||||
#include "handlermgr.h"
|
||||
#include "gameclientmgr.h"
|
||||
#if MASTER_MODE
|
||||
#include "mastersvrmgr.h"
|
||||
#endif
|
||||
|
||||
class GCClientSession: public a8::WebSocketSession
|
||||
{
|
||||
@ -27,13 +33,15 @@ public:
|
||||
if (buflen - offset < sizeof(f8::PackHead) + p->packlen) {
|
||||
break;
|
||||
}
|
||||
App::Instance()->AddSocketMsg(SF_Client,
|
||||
socket_handle,
|
||||
saddr,
|
||||
p->msgid,
|
||||
p->seqid,
|
||||
&buf[offset + sizeof(f8::PackHead)],
|
||||
p->packlen);
|
||||
if (p->msgid > im::MaxIMMsgId) {
|
||||
App::Instance()->AddSocketMsg(SF_Client,
|
||||
socket_handle,
|
||||
saddr,
|
||||
p->msgid,
|
||||
p->seqid,
|
||||
&buf[offset + sizeof(f8::PackHead)],
|
||||
p->packlen);
|
||||
}
|
||||
offset += sizeof(f8::PackHead) + p->packlen;
|
||||
} else {
|
||||
warning = true;
|
||||
@ -61,6 +69,20 @@ public:
|
||||
virtual bool HandleRedirect(const std::string& url, const std::string& querystr,
|
||||
std::string& location) override
|
||||
{
|
||||
im::IMSocketConnect msg;
|
||||
msg.set_is_websocket(true);
|
||||
msg.set_url(url);
|
||||
msg.set_query_str(querystr);
|
||||
|
||||
std::string data;
|
||||
msg.SerializeToString(&data);
|
||||
App::Instance()->AddSocketMsg(SF_Client,
|
||||
socket_handle,
|
||||
saddr,
|
||||
im::_IMSocketConnect,
|
||||
0,
|
||||
data.data(),
|
||||
data.size());
|
||||
#if MASTER_MODE
|
||||
a8::HTTPRequest request;
|
||||
a8::ParserUrlQueryString(querystr.c_str(), request);
|
||||
@ -90,10 +112,16 @@ public:
|
||||
|
||||
virtual void OnDisConnect() override
|
||||
{
|
||||
App::Instance()->AddIMMsg(IM_ClientSocketDisconnect,
|
||||
a8::XParams()
|
||||
.SetSender(socket_handle)
|
||||
.SetParam1(1));
|
||||
im::IMSocketDisconnect msg;
|
||||
std::string data;
|
||||
msg.SerializeToString(&data);
|
||||
App::Instance()->AddSocketMsg(SF_Client,
|
||||
socket_handle,
|
||||
saddr,
|
||||
im::_IMSocketDisconnect,
|
||||
0,
|
||||
data.data(),
|
||||
data.size());
|
||||
}
|
||||
|
||||
};
|
||||
@ -125,6 +153,36 @@ void GCListener::UnInit()
|
||||
tcp_listener_ = nullptr;
|
||||
}
|
||||
|
||||
void GCListener::_F8_IMSocketConnect(f8::MsgHdr& hdr, const im::IMSocketConnect& msg)
|
||||
{
|
||||
if (msg.url().size() > 1024) {
|
||||
a8::UdpLog::Instance()->Warning("websokcet connect url to long %s %s",
|
||||
{
|
||||
msg.url(),
|
||||
msg.query_str()
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (msg.query_str().size() > 1024) {
|
||||
a8::UdpLog::Instance()->Warning("websokcet connect query_str to long %s %s",
|
||||
{
|
||||
msg.url(),
|
||||
msg.query_str()
|
||||
});
|
||||
return;
|
||||
}
|
||||
websocket_url_hash_[hdr.socket_handle] = std::make_tuple(msg.url(), msg.query_str());
|
||||
}
|
||||
|
||||
void GCListener::_F8_IMSocketDisconnect(f8::MsgHdr& hdr, const im::IMSocketDisconnect& msg)
|
||||
{
|
||||
GameClientMgr::Instance()->OnClientDisconnect(hdr.socket_handle);
|
||||
#if MASTER_MODE
|
||||
MasterSvrMgr::Instance()->RemoveRequestBySocketHandle(hdr.socket_handle, true);
|
||||
#endif
|
||||
websocket_url_hash_.erase(hdr.socket_handle);
|
||||
}
|
||||
|
||||
void GCListener::ForwardTargetConnMsg(f8::MsgHdr& hdr)
|
||||
{
|
||||
char* buff = (char*)malloc(sizeof(f8::PackHead) + hdr.buflen);
|
||||
@ -166,3 +224,15 @@ long long GCListener::GetSentBytesNum()
|
||||
{
|
||||
return tcp_listener_->sent_bytes_num;
|
||||
}
|
||||
|
||||
bool GCListener::GetWebSocketUrl(int socket_handle, std::string& url, std::string& query_str)
|
||||
{
|
||||
auto itr = websocket_url_hash_.find(socket_handle);
|
||||
if (itr != websocket_url_hash_.end()) {
|
||||
url = std::get<0>(itr->second);
|
||||
query_str = std::get<1>(itr->second);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,17 @@ namespace a8
|
||||
class TcpListener;
|
||||
}
|
||||
|
||||
namespace f8
|
||||
{
|
||||
struct MsgHdr;
|
||||
}
|
||||
|
||||
namespace im
|
||||
{
|
||||
class IMSocketConnect;
|
||||
class IMSocketDisconnect;
|
||||
}
|
||||
|
||||
class GCListener : public a8::Singleton<GCListener>
|
||||
{
|
||||
private:
|
||||
@ -26,6 +37,9 @@ class GCListener : public a8::Singleton<GCListener>
|
||||
f8::Net_SendMsg(tcp_listener_, socket_handle, 0, msgid, msg);
|
||||
}
|
||||
|
||||
void _F8_IMSocketConnect(f8::MsgHdr& hdr, const im::IMSocketConnect& msg);
|
||||
void _F8_IMSocketDisconnect(f8::MsgHdr& hdr, const im::IMSocketDisconnect& msg);
|
||||
|
||||
void ForwardTargetConnMsg(f8::MsgHdr& hdr);
|
||||
void SendText(unsigned short sockhandle, const std::string& text);
|
||||
|
||||
@ -33,7 +47,9 @@ class GCListener : public a8::Singleton<GCListener>
|
||||
void MarkClient(unsigned short sockhandle, bool is_active);
|
||||
long long GetSendNodeNum();
|
||||
long long GetSentBytesNum();
|
||||
bool GetWebSocketUrl(int socket_handle, std::string& url, std::string& query_str);
|
||||
|
||||
private:
|
||||
std::map<int, std::tuple<std::string, std::string>> websocket_url_hash_;
|
||||
a8::TcpListener *tcp_listener_ = nullptr;
|
||||
};
|
||||
|
@ -419,6 +419,15 @@ void App::DispatchMsg()
|
||||
void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
{
|
||||
if (hdr.msgid < 100) {
|
||||
f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->immsghandler,
|
||||
hdr.msgid);
|
||||
if (handler) {
|
||||
switch (handler->handlerid) {
|
||||
case HID_GCListener:
|
||||
ProcessNetMsg(handler, GCListener::Instance(), hdr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#if MASTER_MODE
|
||||
@ -434,6 +443,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
MasterSvrMgr::Instance()->RequestTargetServer(hdr,
|
||||
msg.team_uuid(),
|
||||
msg.account_id(),
|
||||
msg.session_id(),
|
||||
"",
|
||||
0,
|
||||
msg.proto_version());
|
||||
@ -448,6 +458,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
MasterSvrMgr::Instance()->RequestTargetServer(hdr,
|
||||
msg.team_uuid(),
|
||||
msg.account_id(),
|
||||
msg.session_id(),
|
||||
msg.server_info(),
|
||||
1,
|
||||
0);
|
||||
@ -541,14 +552,6 @@ void App::ProcessIMMsg()
|
||||
while (im_work_node_) {
|
||||
IMMsgNode *pdelnode = im_work_node_;
|
||||
switch (im_work_node_->msgid) {
|
||||
case IM_ClientSocketDisconnect:
|
||||
{
|
||||
GameClientMgr::Instance()->OnClientDisconnect(pdelnode->params);
|
||||
#if MASTER_MODE
|
||||
MasterSvrMgr::Instance()->RemoveRequest(pdelnode->params.param1, pdelnode->params.sender, true);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case IM_TargetConnConnect:
|
||||
{
|
||||
GameClientMgr::Instance()->OnTargetServerConnect(pdelnode->params);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
enum SocketFrom_e
|
||||
{
|
||||
@ -9,8 +9,7 @@ enum SocketFrom_e
|
||||
|
||||
enum InnerMesssage_e
|
||||
{
|
||||
IM_ClientSocketDisconnect = 100,
|
||||
IM_PlayerOffline,
|
||||
IM_PlayerOffline = 100,
|
||||
IM_ExecGM,
|
||||
IM_TargetConnDisconnect,
|
||||
IM_MasterSvrDisconnect,
|
||||
|
@ -22,18 +22,18 @@ void GameClientMgr::UnInit()
|
||||
pending_account_hash_.clear();
|
||||
}
|
||||
|
||||
void GameClientMgr::OnClientDisconnect(a8::XParams& param)
|
||||
void GameClientMgr::OnClientDisconnect(int socket_handle)
|
||||
{
|
||||
GameClient* client = GetGameClientBySocket(param.sender);
|
||||
GameClient* client = GetGameClientBySocket(socket_handle);
|
||||
if (client) {
|
||||
if (client->conn) {
|
||||
ss::SS_WSP_SocketDisconnect msg;
|
||||
client->conn->SendMsg(param.sender, msg);
|
||||
client->conn->SendMsg(socket_handle, msg);
|
||||
}
|
||||
socket_hash_.erase(param.sender);
|
||||
socket_hash_.erase(socket_handle);
|
||||
delete client;
|
||||
}
|
||||
RemovePendingAccount(param.sender);
|
||||
RemovePendingAccount(socket_handle);
|
||||
}
|
||||
|
||||
void GameClientMgr::OnTargetServerDisconnect(a8::XParams& param)
|
||||
|
@ -14,7 +14,7 @@ class GameClientMgr : public a8::Singleton<GameClientMgr>
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
void OnClientDisconnect(a8::XParams& param);
|
||||
void OnClientDisconnect(int socket_handle);
|
||||
void OnTargetServerDisconnect(a8::XParams& param);
|
||||
void OnTargetServerConnect(a8::XParams& param);
|
||||
GameClient* GetGameClientBySocket(int sockhande);
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "ss_proto.pb.h"
|
||||
|
||||
#include "framework/cpp/im_msgid.pb.h"
|
||||
#include "framework/cpp/im_proto.pb.h"
|
||||
|
||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
@ -38,6 +41,9 @@ void HandlerMgr::UnInit()
|
||||
|
||||
void HandlerMgr::RegisterNetMsgHandlers()
|
||||
{
|
||||
RegisterNetMsgHandler(&immsghandler, &GCListener::_F8_IMSocketConnect);
|
||||
RegisterNetMsgHandler(&immsghandler, &GCListener::_F8_IMSocketDisconnect);
|
||||
|
||||
RegisterNetMsgHandler(&msmsghandler, &MasterSvrMgr::_SS_MS_ResponseTargetServer);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ class HandlerMgr : public a8::Singleton<HandlerMgr>
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
f8::NetMsgHandlerObject immsghandler;
|
||||
f8::NetMsgHandlerObject gcmsghandler;
|
||||
f8::NetMsgHandlerObject msmsghandler;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "target_conn_mgr.h"
|
||||
#include "app.h"
|
||||
#include "gameclientmgr.h"
|
||||
#include "GCListener.h"
|
||||
|
||||
#include "framework/cpp/netmsghandler.h"
|
||||
|
||||
@ -71,6 +72,7 @@ MasterSvr* MasterSvrMgr::GetConnById(int instance_id)
|
||||
void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
const std::string& team_id,
|
||||
const std::string& account_id,
|
||||
const std::string& session_id,
|
||||
const std::string& server_info,
|
||||
int is_reconnect,
|
||||
int proto_version)
|
||||
@ -118,10 +120,18 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
||||
ss::SS_WSP_RequestTargetServer msg;
|
||||
msg.set_context_id(curr_context_id_);
|
||||
msg.set_account_id(account_id);
|
||||
msg.set_session_id(session_id);
|
||||
msg.set_team_id(team_uuid);
|
||||
msg.set_server_info(server_info);
|
||||
msg.set_is_reconnect(is_reconnect);
|
||||
msg.set_proto_version(proto_version);
|
||||
std::string url;
|
||||
std::string query_str;
|
||||
{
|
||||
GCListener::Instance()->GetWebSocketUrl(hdr.socket_handle, url, query_str);
|
||||
}
|
||||
msg.set_url(url);
|
||||
msg.set_query_str(query_str);
|
||||
svr->SendMsg(msg);
|
||||
|
||||
pending_socket_hash_[hdr.socket_handle] = curr_context_id_;
|
||||
@ -195,6 +205,14 @@ void MasterSvrMgr::RemoveRequest(int socket_handle, long long context_id, bool a
|
||||
}
|
||||
}
|
||||
|
||||
void MasterSvrMgr::RemoveRequestBySocketHandle(int socket_handle, bool auto_free)
|
||||
{
|
||||
long long context_id = GetContextIdBySocket(socket_handle);
|
||||
if (context_id != 0) {
|
||||
RemoveRequest(socket_handle, context_id, auto_free);
|
||||
}
|
||||
}
|
||||
|
||||
long long MasterSvrMgr::GetContextIdBySocket(int socket_handle)
|
||||
{
|
||||
auto itr = pending_socket_hash_.find(socket_handle);
|
||||
|
@ -29,10 +29,12 @@ class MasterSvrMgr : public a8::Singleton<MasterSvrMgr>
|
||||
void RequestTargetServer(f8::MsgHdr& hdr,
|
||||
const std::string& team_id,
|
||||
const std::string& account_id,
|
||||
const std::string& session_id,
|
||||
const std::string& server_info,
|
||||
int is_reconnect,
|
||||
int proto_version);
|
||||
void RemoveRequest(int socket_handle, long long context_id, bool auto_free);
|
||||
void RemoveRequestBySocketHandle(int socket_handle, bool auto_free);
|
||||
|
||||
private:
|
||||
long long GetContextIdBySocket(int socket_handle);
|
||||
|
2
third_party/a8engine
vendored
2
third_party/a8engine
vendored
@ -1 +1 @@
|
||||
Subproject commit a369c484113b240f042c62cba80afd26df91e4ca
|
||||
Subproject commit 27ecd5c940b420b91da7450b66468cee51fa1eb0
|
2
third_party/framework
vendored
2
third_party/framework
vendored
@ -1 +1 @@
|
||||
Subproject commit 9ba2696e52664c9f5b7a1e09a4a5516359d330b0
|
||||
Subproject commit ea69b96451e7004430e99b86db1cfd3ae4d76c6b
|
Loading…
x
Reference in New Issue
Block a user