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