feat 废弃jwt 、 学识分

This commit is contained in:
2026-02-06 22:31:29 +08:00
parent b1dfb88f71
commit 456f1970eb
17 changed files with 236 additions and 156 deletions

View File

@@ -29,11 +29,10 @@ type Client struct {
UniqueNo int64 // 副本唯一编号
}
func NewClient(usn int64, conn socket.ISocketConn) *Client {
func NewClient(conn socket.ISocketConn) *Client {
client := &Client{
USN: usn,
conn: conn,
logger: log.GetLogger().Named(fmt.Sprintf("usn:%v", usn)),
logger: log.GetLogger(),
heartBeat: time.Now(),
mailChan: make(chan Event, 1024),
}
@@ -43,6 +42,11 @@ func NewClient(usn int64, conn socket.ISocketConn) *Client {
return client
}
func (c *Client) SetUSN(usn int64) {
c.USN = usn
c.logger = log.GetLogger().Named(fmt.Sprintf("usn:%v", usn))
}
func (c *Client) Loop() {
defer func() {
if err := recover(); err != nil {

View File

@@ -8,6 +8,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
"git.hlsq.asia/mmorpg/service-common/utils"
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
"sync"
@@ -152,7 +153,9 @@ func (l *Login) StartLogin(user *User) {
// CheckToken 校验Token是否有效
func (l *Login) CheckToken(user *User) bool {
return redis.GetClient().Get(l.ctx, fmt.Sprintf(global.KeyGatewayAccessToken, user.Cli.USN)).Val() == user.Token
usn, _ := redis.GetClient().HGet(context.Background(), global.KeyGatewayAccessToken+user.Token, (&utils.UserSession{}).GetUsnKey()).Int64()
user.Cli.SetUSN(usn)
return usn > 0
}
// CheckOnline 校验是否在线