From 39b01b279473a6044e0d35c93e120f452823455d Mon Sep 17 00:00:00 2001 From: azw Date: Mon, 5 Jun 2023 09:40:34 +0000 Subject: [PATCH] 1 --- server/wsproxy/kcpsession.cc | 8 ++------ server/wsproxy/kcpsession.h | 3 +-- server/wsproxy/longsession.cc | 10 ++++------ server/wsproxy/longsession.h | 1 - 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/server/wsproxy/kcpsession.cc b/server/wsproxy/kcpsession.cc index 521f8b3..626b2d0 100644 --- a/server/wsproxy/kcpsession.cc +++ b/server/wsproxy/kcpsession.cc @@ -33,7 +33,7 @@ KcpSession::~KcpSession() } -void KcpSession::Init(int socket_handle) +void KcpSession::Init(int socket_handle, int secret_key_place) { socket_handle_ = socket_handle; secret_key_ = App::Instance()->NewUuid(); @@ -50,6 +50,7 @@ void KcpSession::Init(int socket_handle) kcp_->rx_minrto = 10; kcp_->fastresend = 1; #endif + secret_key_place_ = secret_key_place; kcp_->output = UdpOutput; init_tick_ = a8::XGetTickCount(); } @@ -128,11 +129,6 @@ void KcpSession::DecodeUserPacket(char* buf, int& offset, unsigned int buflen) } } -void KcpSession::SetSecretKeyPlace(int secret_key_place) -{ - secret_key_place_ = secret_key_place; -} - int KcpSession::GetSecretKeyPlace() { return secret_key_place_; diff --git a/server/wsproxy/kcpsession.h b/server/wsproxy/kcpsession.h index 425a218..8a8775c 100644 --- a/server/wsproxy/kcpsession.h +++ b/server/wsproxy/kcpsession.h @@ -11,7 +11,7 @@ public: KcpSession(); ~KcpSession(); - void Init(int socket_handle); + void Init(int socket_handle, int secret_key_place); void UnInit(); void Update(long long tick); @@ -19,7 +19,6 @@ public: int GetSocketHandle() { return socket_handle_; } long long GetSecretKey() { return secret_key_; } void* GetSecretKeyDataPtr() { return &secret_key_; } - void SetSecretKeyPlace(int secret_key_place); int GetSecretKeyPlace(); void SendClientMsg(char* buf, int buf_len); diff --git a/server/wsproxy/longsession.cc b/server/wsproxy/longsession.cc index 3ef3db0..f41b158 100644 --- a/server/wsproxy/longsession.cc +++ b/server/wsproxy/longsession.cc @@ -5,10 +5,13 @@ #include "longsession.h" #include "kcpsession.h" +#include "ss_msgid.pb.h" +#include "ss_proto.pb.h" + void LongSession::Init(f8::MsgHdr& hdr, const ss::SS_CMKcpHandshake& msg) { kcp_session_ = std::make_shared(); - kcp_session_->Init(hdr.socket_handle); + kcp_session_->Init(hdr.socket_handle, msg.secret_key_place()); } void LongSession::UnInit() @@ -26,11 +29,6 @@ void LongSession::UpdatePing() last_ping_tick_ = a8::XGetTickCount(); } -void LongSession::SetSecretKeyPlace(int secret_key_place) -{ - kcp_session_->SetSecretKeyPlace(secret_key_place); -} - int LongSession::GetSecretKeyPlace() { return kcp_session_->GetSecretKeyPlace(); diff --git a/server/wsproxy/longsession.h b/server/wsproxy/longsession.h index 02a657d..41ec1d0 100644 --- a/server/wsproxy/longsession.h +++ b/server/wsproxy/longsession.h @@ -17,7 +17,6 @@ class LongSession std::shared_ptr GetKcpSession() { return kcp_session_; } void UpdatePing(); - void SetSecretKeyPlace(int secret_key_place); int GetSecretKeyPlace(); private: