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