diff --git a/server/wsproxy/kcpsession.cc b/server/wsproxy/kcpsession.cc index 0438bea..eed02d4 100644 --- a/server/wsproxy/kcpsession.cc +++ b/server/wsproxy/kcpsession.cc @@ -49,9 +49,8 @@ void KcpSession::UnInit() } } -void KcpSession::Update() +void KcpSession::Update(long long tick) { - long long tick = a8::XGetTickCount(); ikcp_update(kcp_, tick - init_tick_); UpdateInput(); } diff --git a/server/wsproxy/kcpsession.h b/server/wsproxy/kcpsession.h index 7d7ca52..1de61ca 100644 --- a/server/wsproxy/kcpsession.h +++ b/server/wsproxy/kcpsession.h @@ -11,7 +11,8 @@ public: void Init(a8::UdpListener* udp_listener, int socket_handle, a8::UdpPacket* pkt); void UnInit(); - void Update(); + void Update(long long tick); + void SendClientMsg(char* buf, int buf_len); void OnRecvPacket(a8::UdpPacket* pkt); const sockaddr_in& GetAddr() const { return remote_addr_; } diff --git a/server/wsproxy/longsession.cc b/server/wsproxy/longsession.cc index 27c23a6..a2148f8 100644 --- a/server/wsproxy/longsession.cc +++ b/server/wsproxy/longsession.cc @@ -15,15 +15,5 @@ void LongSession::UnInit() void LongSession::Update(long long tick) { - -} - -int LongSession::GetSocketHandle() -{ - return kcp_session_->GetSocketHandle(); -} - -long long LongSession::GetSecretKey() -{ - return kcp_session_->GetSecretKey(); + GetKcpSession()->Update(tick); } diff --git a/server/wsproxy/longsession.h b/server/wsproxy/longsession.h index 024a09a..2c668b7 100644 --- a/server/wsproxy/longsession.h +++ b/server/wsproxy/longsession.h @@ -10,8 +10,6 @@ class LongSession void UnInit(); void Update(long long tick); - int GetSocketHandle(); - long long GetSecretKey(); std::shared_ptr GetKcpSession() { return kcp_session_; } private: diff --git a/server/wsproxy/longsessionmgr.cc b/server/wsproxy/longsessionmgr.cc index cd656cd..459ccaa 100644 --- a/server/wsproxy/longsessionmgr.cc +++ b/server/wsproxy/longsessionmgr.cc @@ -55,7 +55,7 @@ void LongSessionMgr::ProcUdpPacket(a8::UdpPacket* pkt) int socket_handle = 0; long long secret_key = 0; auto session = GetSession(socket_handle); - if (session && secret_key == session->GetSecretKey()) { + if (session && secret_key == session->GetKcpSession()->GetSecretKey()) { session->GetKcpSession()->OnRecvPacket(pkt); } }