This commit is contained in:
azw 2023-06-05 09:40:34 +00:00
parent 36f7099354
commit 39b01b2794
4 changed files with 7 additions and 15 deletions

View File

@ -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_;

View File

@ -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);

View File

@ -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<KcpSession>();
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();

View File

@ -17,7 +17,6 @@ class LongSession
std::shared_ptr<KcpSession> GetKcpSession() { return kcp_session_; }
void UpdatePing();
void SetSecretKeyPlace(int secret_key_place);
int GetSecretKeyPlace();
private: