1
This commit is contained in:
parent
39e1c883b6
commit
0c1f08b877
@ -14,6 +14,6 @@ void DownStream::OnClose()
|
|||||||
{
|
{
|
||||||
if (!GetUpStream().expired()) {
|
if (!GetUpStream().expired()) {
|
||||||
ss::SS_WSP_SocketDisconnect msg;
|
ss::SS_WSP_SocketDisconnect msg;
|
||||||
GetUpStream().lock()->SendMsg(socket_handle, msg);
|
GetUpStream().lock()->SendMsg(socket_handle_, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,17 @@ class UpStream;
|
|||||||
class DownStream
|
class DownStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int socket_handle = a8::INVALID_SOCKET_HANDLE;
|
|
||||||
|
|
||||||
void SetUpStream(std::weak_ptr<UpStream> up) { up_ = up; }
|
int GetSocketHandle() { return socket_handle_; }
|
||||||
|
void SetSocketHandle(int socket_handle) { socket_handle_ = socket_handle; }
|
||||||
std::weak_ptr<UpStream> GetUpStream() { return up_; }
|
std::weak_ptr<UpStream> GetUpStream() { return up_; }
|
||||||
|
void SetUpStream(std::weak_ptr<UpStream> up) { up_ = up; }
|
||||||
|
|
||||||
void ForwardUpStreamMsg(f8::MsgHdr& hdr);
|
void ForwardUpStreamMsg(f8::MsgHdr& hdr);
|
||||||
void OnClose();
|
void OnClose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int socket_handle_ = a8::INVALID_SOCKET_HANDLE;
|
||||||
int type_ = 0;
|
int type_ = 0;
|
||||||
std::weak_ptr<UpStream> up_;
|
std::weak_ptr<UpStream> up_;
|
||||||
};
|
};
|
||||||
|
@ -60,9 +60,9 @@ void DownStreamMgr::OnUpStreamDisconnect(int instance_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& client : delete_client) {
|
for (auto& client : delete_client) {
|
||||||
RemovePendingAccount(client->socket_handle);
|
RemovePendingAccount(client->GetSocketHandle());
|
||||||
GCListener::Instance()->ForceCloseClient(client->socket_handle);
|
GCListener::Instance()->ForceCloseClient(client->GetSocketHandle());
|
||||||
socket_hash_.erase(client->socket_handle);
|
socket_hash_.erase(client->GetSocketHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,16 +79,16 @@ std::weak_ptr<DownStream> DownStreamMgr::GetDownStream(int sockhandle)
|
|||||||
|
|
||||||
void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
|
void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
|
||||||
{
|
{
|
||||||
std::weak_ptr<UpStream> conn = UpStreamMgr::Instance()->GetUpStreamById(conn_instance_id);
|
std::weak_ptr<UpStream> up_wp = UpStreamMgr::Instance()->GetUpStreamById(conn_instance_id);
|
||||||
if (!conn.expired()) {
|
if (!up_wp.expired()) {
|
||||||
auto down_wp = GetDownStream(socket_handle);
|
auto down_wp = GetDownStream(socket_handle);
|
||||||
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
||||||
down->SetUpStream(conn);
|
down->SetUpStream(up_wp);
|
||||||
} else {
|
} else {
|
||||||
down = std::make_shared<DownStream>();
|
down = std::make_shared<DownStream>();
|
||||||
down->socket_handle = socket_handle;
|
down->SetSocketHandle(socket_handle);
|
||||||
down->SetUpStream(conn);
|
down->SetUpStream(up_wp);
|
||||||
socket_hash_[down->socket_handle] = down;
|
socket_hash_[down->GetSocketHandle()] = down;
|
||||||
f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d",
|
f8::UdpLog::Instance()->Info("BindUpStream socket_handle:%d",
|
||||||
{
|
{
|
||||||
socket_handle
|
socket_handle
|
||||||
|
@ -15,9 +15,9 @@ void UpStreamMgr::Init()
|
|||||||
[this] (const a8::Args& args)
|
[this] (const a8::Args& args)
|
||||||
{
|
{
|
||||||
int instance_id = args.Get<int>(0);
|
int instance_id = args.Get<int>(0);
|
||||||
std::weak_ptr<UpStream> conn = GetUpStreamById(instance_id);
|
std::weak_ptr<UpStream> up_wp = GetUpStreamById(instance_id);
|
||||||
if (!conn.expired() && conn.lock()->Connected()) {
|
if (!up_wp.expired() && up_wp.lock()->Connected()) {
|
||||||
conn.lock()->SendStockMsg();
|
up_wp.lock()->SendStockMsg();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
f8::MsgQueue::Instance()->RegisterCallBack
|
f8::MsgQueue::Instance()->RegisterCallBack
|
||||||
|
Loading…
x
Reference in New Issue
Block a user