Files
bl/logic/service/login/LoginSidInfo.go
昔念 8fb792b0f2 build: 更新依赖并添加新库
- 更新 go.mod 和 go.sum 文件,添加多个新库
- 在 LoginSidInfo 结构体中添加注释说明
- 在 cmd.go 中添加 TODO 注释
2025-07-02 22:18:29 +08:00

35 lines
975 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package login
import (
"blazing/common/socket/handler"
"blazing/cool"
"context"
"encoding/hex"
"fmt"
"strings"
)
// LoginSidInfo 登录携带的凭证结构体
type LoginSidInfo struct { //这里直接使用组合来实现将传入的原始头部数据和结构体参数序列化
Head handler.TomeeHeader `cmd:"1001" struc:"[0]pad"` //玩家登录
Sid []byte `struc:"[16]byte"` // 登录会话ID固定长度16字节
// NotLogin uint32 `error="10001"|struc:"[0]pad"` //返回错误码 ,不序列化,仅作为错误码
// ErrorPassWord uint32 `struc:"[0]pad"`
}
func (l *LoginSidInfo) CheakSession() bool {
// tt, _ := cool.CacheManager.Keys(context.Background())
//g.Dump(tt)
t1 := hex.EncodeToString(l.Sid)
t2 := strings.Trim(t1, " ")
t, err := cool.CacheManager.Get(context.Background(), t2)
fmt.Println("后端获取", string(l.Sid), t, err)
if t.Uint32() == l.Head.UserID {
return true
}
return false
}