1
This commit is contained in:
parent
19f75b6929
commit
d1c308e156
@ -17,8 +17,6 @@
|
||||
#include "WSListener.h"
|
||||
#include "jsondatamgr.h"
|
||||
#include "handlermgr.h"
|
||||
#include "gameclient.h"
|
||||
#include "gameclientmgr.h"
|
||||
#include "ss_msgid.pb.h"
|
||||
#include "ss_proto.pb.h"
|
||||
|
||||
@ -122,7 +120,6 @@ bool App::Init(int argc, char* argv[])
|
||||
a8::IoLoop::Instance()->Init(1);
|
||||
JsonDataMgr::Instance()->Init();
|
||||
uuid.SetMachineId(instance_id);
|
||||
GameClientMgr::Instance()->Init();
|
||||
IMConnMgr::Instance()->Init();
|
||||
MSConnMgr::Instance()->Init();
|
||||
WSListener::Instance()->Init();
|
||||
@ -175,7 +172,6 @@ void App::UnInit()
|
||||
WSListener::Instance()->UnInit();
|
||||
IMConnMgr::Instance()->UnInit();
|
||||
MSConnMgr::Instance()->UnInit();
|
||||
GameClientMgr::Instance()->UnInit();
|
||||
JsonDataMgr::Instance()->UnInit();
|
||||
a8::IoLoop::Instance()->UnInit();
|
||||
a8::Timer::Instance()->UnInit();
|
||||
@ -400,6 +396,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#if 0
|
||||
GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||
if (client && client->conn) {
|
||||
if (client->conn) {
|
||||
@ -408,6 +405,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,7 +434,9 @@ void App::ProcessTargetServerMsg(f8::MsgHdr& hdr)
|
||||
return;
|
||||
}
|
||||
if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReConnect) {
|
||||
#if 0
|
||||
GameClientMgr::Instance()->BindTargetConn(hdr.socket_handle, hdr.ip_saddr);
|
||||
#endif
|
||||
WSListener::Instance()->MarkClient(hdr.socket_handle, true);
|
||||
}
|
||||
WSListener::Instance()->ForwardTargetConnMsg(hdr);
|
||||
@ -456,8 +456,8 @@ void App::ProcessIMMsg()
|
||||
switch (im_work_node_->msgid) {
|
||||
case IM_WSProxySocketDisconnect:
|
||||
{
|
||||
GameClientMgr::Instance()->OnClientDisconnect(pdelnode->params);
|
||||
#if 0
|
||||
GameClientMgr::Instance()->OnClientDisconnect(pdelnode->params);
|
||||
MasterSvrMgr::Instance()->RemoveRequest(pdelnode->params.param1, pdelnode->params.sender, true);
|
||||
#endif
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "gameclient.h"
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class TargetConn;
|
||||
class GameClient
|
||||
{
|
||||
public:
|
||||
int socket_handle = a8::INVALID_SOCKET_HANDLE;
|
||||
TargetConn* conn = nullptr;
|
||||
|
||||
};
|
@ -1,131 +0,0 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "gameclientmgr.h"
|
||||
#include "ss_proto.pb.h"
|
||||
|
||||
#include "gameclient.h"
|
||||
#include "WSListener.h"
|
||||
#include "app.h"
|
||||
|
||||
void GameClientMgr::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void GameClientMgr::UnInit()
|
||||
{
|
||||
for (auto& pair : socket_hash_) {
|
||||
delete pair.second;
|
||||
}
|
||||
socket_hash_.clear();
|
||||
pending_account_hash_.clear();
|
||||
}
|
||||
|
||||
void GameClientMgr::OnClientDisconnect(a8::XParams& param)
|
||||
{
|
||||
GameClient* client = GetGameClientBySocket(param.sender);
|
||||
if (client) {
|
||||
if (client->conn) {
|
||||
ss::SS_WSP_SocketDisconnect msg;
|
||||
#if 0
|
||||
client->conn->SendMsg(param.sender, msg);
|
||||
#endif
|
||||
}
|
||||
socket_hash_.erase(param.sender);
|
||||
delete client;
|
||||
}
|
||||
RemovePendingAccount(param.sender);
|
||||
}
|
||||
|
||||
void GameClientMgr::OnTargetServerDisconnect(a8::XParams& param)
|
||||
{
|
||||
std::list<GameClient*> delete_client;
|
||||
for (auto& pair : socket_hash_) {
|
||||
#if 0
|
||||
if (pair.second->conn && pair.second->conn->instance_id == param.sender.GetInt()) {
|
||||
delete_client.push_back(pair.second);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
for (auto& client : delete_client) {
|
||||
RemovePendingAccount(client->socket_handle);
|
||||
WSListener::Instance()->ForceCloseClient(client->socket_handle);
|
||||
socket_hash_.erase(client->socket_handle);
|
||||
delete client;
|
||||
}
|
||||
}
|
||||
|
||||
void GameClientMgr::OnTargetServerConnect(a8::XParams& param)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GameClient* GameClientMgr::GetGameClientBySocket(int sockhandle)
|
||||
{
|
||||
auto itr = socket_hash_.find(sockhandle);
|
||||
return itr != socket_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
void GameClientMgr::BindTargetConn(int socket_handle, int conn_instance_id)
|
||||
{
|
||||
#if 0
|
||||
TargetConn* conn = TargetConnMgr::Instance()->GetConnById(conn_instance_id);
|
||||
if (conn) {
|
||||
GameClient* client = GetGameClientBySocket(socket_handle);
|
||||
if (client) {
|
||||
client->conn = conn;
|
||||
} else {
|
||||
client = new GameClient();
|
||||
client->socket_handle = socket_handle;
|
||||
client->conn = conn;
|
||||
socket_hash_[client->socket_handle] = client;
|
||||
a8::UdpLog::Instance()->Info("BindTargetConn socket_handle:%d", {socket_handle});
|
||||
{
|
||||
auto itr = pending_account_hash_.find(socket_handle);
|
||||
if (itr != pending_account_hash_.end()) {
|
||||
std::string account_id = std::get<0>(itr->second);
|
||||
long long req_tick = std::get<1>(itr->second);
|
||||
long long cur_tick = a8::XGetTickCount();
|
||||
if (cur_tick - req_tick > App::Instance()->perf.max_join_time) {
|
||||
App::Instance()->perf.max_join_time = cur_tick - req_tick;
|
||||
}
|
||||
a8::UdpLog::Instance()->Info("BindTargetConn account_id:%s", {account_id});
|
||||
RemovePendingAccount(socket_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GameClientMgr::AddPendingAccount(const std::string& account_id, int socket_handle, long long req_tick)
|
||||
{
|
||||
a8::UdpLog::Instance()->Info("AddPendingAccount %s %d", {account_id, socket_handle});
|
||||
auto itr = pending_account_hash_.find(socket_handle);
|
||||
if (itr == pending_account_hash_.end()){
|
||||
timer_list* timer = a8::Timer::Instance()->AddDeadLineTimerAndAttach(1000 * 10,
|
||||
a8::XParams()
|
||||
.SetSender(socket_handle),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
GameClientMgr::Instance()->pending_account_hash_.erase(param.sender);
|
||||
App::Instance()->perf.max_join_time = std::max((long long)1000 * 10, App::Instance()->perf.max_join_time);
|
||||
},
|
||||
&timer_attacher_.timer_list_
|
||||
);
|
||||
pending_account_hash_[socket_handle] = std::make_tuple(
|
||||
account_id,
|
||||
req_tick,
|
||||
timer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void GameClientMgr::RemovePendingAccount(int socket_handle)
|
||||
{
|
||||
a8::UdpLog::Instance()->Info("RemovePendingAccount %d", {socket_handle});
|
||||
auto itr = pending_account_hash_.find(socket_handle);
|
||||
if (itr != pending_account_hash_.end()) {
|
||||
a8::Timer::Instance()->DeleteTimer(std::get<2>(itr->second));
|
||||
pending_account_hash_.erase(itr);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <a8/timer.h>
|
||||
|
||||
class GameClient;
|
||||
class GameClientMgr : public a8::Singleton<GameClientMgr>
|
||||
{
|
||||
private:
|
||||
GameClientMgr() {};
|
||||
friend class a8::Singleton<GameClientMgr>;
|
||||
|
||||
public:
|
||||
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
void OnClientDisconnect(a8::XParams& param);
|
||||
void OnTargetServerDisconnect(a8::XParams& param);
|
||||
void OnTargetServerConnect(a8::XParams& param);
|
||||
GameClient* GetGameClientBySocket(int sockhande);
|
||||
void BindTargetConn(int socket_handle, int conn_instance_id);
|
||||
void AddPendingAccount(const std::string& account_id, int socket_handle, long long req_tick);
|
||||
|
||||
private:
|
||||
|
||||
void RemovePendingAccount(int socket_handle);
|
||||
|
||||
private:
|
||||
a8::TimerAttacher timer_attacher_;
|
||||
std::map<int, GameClient*> socket_hash_;
|
||||
std::map<int, std::tuple<std::string, long long, timer_list*>> pending_account_hash_;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user