1
This commit is contained in:
parent
a3bf6bd99d
commit
89816f516a
@ -344,8 +344,8 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
return;
|
||||
}
|
||||
if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReconnect) {
|
||||
DownStream* client = DownStreamMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||
if (!client) {
|
||||
auto down_wp = DownStreamMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
||||
switch (hdr.msgid) {
|
||||
case ss::_SS_CMLogin:
|
||||
{
|
||||
@ -385,10 +385,10 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DownStream* client = DownStreamMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||
if (client && client->conn) {
|
||||
if (client->conn) {
|
||||
client->conn->ForwardClientMsg(hdr);
|
||||
auto down_wp = DownStreamMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
||||
if (down->conn) {
|
||||
down->conn->ForwardClientMsg(hdr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,6 @@ void DownStreamMgr::Init()
|
||||
|
||||
void DownStreamMgr::UnInit()
|
||||
{
|
||||
for (auto& pair : socket_hash_) {
|
||||
delete pair.second;
|
||||
}
|
||||
socket_hash_.clear();
|
||||
#if 0
|
||||
pending_account_hash_.clear();
|
||||
@ -37,14 +34,13 @@ void DownStreamMgr::UnInit()
|
||||
|
||||
void DownStreamMgr::OnClientDisconnect(int socket_handle)
|
||||
{
|
||||
DownStream* client = GetGameClientBySocket(socket_handle);
|
||||
if (client) {
|
||||
if (client->conn) {
|
||||
auto down_wp = GetGameClientBySocket(socket_handle);
|
||||
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
||||
if (down->conn) {
|
||||
ss::SS_WSP_SocketDisconnect msg;
|
||||
client->conn->SendMsg(socket_handle, msg);
|
||||
down->conn->SendMsg(socket_handle, msg);
|
||||
}
|
||||
socket_hash_.erase(socket_handle);
|
||||
delete client;
|
||||
}
|
||||
RemovePendingAccount(socket_handle);
|
||||
}
|
||||
@ -74,7 +70,7 @@ void DownStreamMgr::OnTargetServerConnect(a8::XParams& param)
|
||||
}
|
||||
#endif
|
||||
|
||||
DownStream* DownStreamMgr::GetGameClientBySocket(int sockhandle)
|
||||
std::weak_ptr<DownStream> DownStreamMgr::GetGameClientBySocket(int sockhandle)
|
||||
{
|
||||
auto itr = socket_hash_.find(sockhandle);
|
||||
return itr != socket_hash_.end() ? itr->second : nullptr;
|
||||
@ -84,14 +80,14 @@ void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
|
||||
{
|
||||
UpStream* conn = UpStreamMgr::Instance()->GetConnById(conn_instance_id);
|
||||
if (conn) {
|
||||
DownStream* client = GetGameClientBySocket(socket_handle);
|
||||
if (client) {
|
||||
client->conn = conn;
|
||||
auto down_wp = GetGameClientBySocket(socket_handle);
|
||||
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
||||
down->conn = conn;
|
||||
} else {
|
||||
client = new DownStream();
|
||||
client->socket_handle = socket_handle;
|
||||
client->conn = conn;
|
||||
socket_hash_[client->socket_handle] = client;
|
||||
down = std::make_shared<DownStream>();
|
||||
down->socket_handle = socket_handle;
|
||||
down->conn = conn;
|
||||
socket_hash_[down->socket_handle] = down;
|
||||
f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d", {socket_handle});
|
||||
{
|
||||
#if 0
|
||||
|
@ -18,7 +18,7 @@ class DownStreamMgr : public a8::Singleton<DownStreamMgr>
|
||||
void OnTargetServerDisconnect(a8::XParams& param);
|
||||
void OnTargetServerConnect(a8::XParams& param);
|
||||
#endif
|
||||
DownStream* GetGameClientBySocket(int sockhande);
|
||||
std::weak_ptr<DownStream> GetGameClientBySocket(int sockhande);
|
||||
void BindUpStream(int socket_handle, int conn_instance_id);
|
||||
void AddPendingAccount(const std::string& account_id, int socket_handle, long long req_tick);
|
||||
|
||||
@ -29,7 +29,7 @@ private:
|
||||
|
||||
private:
|
||||
a8::Attacher timer_attacher_;
|
||||
std::map<int, DownStream*> socket_hash_;
|
||||
std::map<int, std::shared_ptr<DownStream>> socket_hash_;
|
||||
#if 0
|
||||
std::map<int, std::tuple<std::string, long long, timer_list*>> pending_account_hash_;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user