Files
bl/logic/service/login/in.go
昔念 e25fe776eb refactor(common): 重构 Pack 函数并优化数据处理
- 重构了 Pack 函数,支持处理不同类型的 data 参数
- 优化了数据打包过程,使用反射处理结构体和切片
- 修改了 TomeeHeader 结构体,使用 EnumCommandID 类型
- 调整了 login 相关的结构体定义
- 优化了 main 函数中的数据处理逻辑
2025-06-27 00:30:15 +08:00

35 lines
948 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 { //这里直接使用组合来实现将传入的原始头部数据和结构体参数序列化
Handler handler.TomeeHeader `cmd:"1001" `
Sid []byte `struc:"[16]byte"` // 登录会话ID固定长度16字节
// NotLogin uint32 `error="10001"|struc:"[0]pad"` //返回错误码 ,不序列化,仅作为错误码
// ErrorPassWord uint32 `struc:"[0]pad"`
}
func CheakSession(c LoginSidInfo) bool {
// tt, _ := cool.CacheManager.Keys(context.Background())
//g.Dump(tt)
t1 := hex.EncodeToString(c.Sid)
t2 := strings.Trim(t1, " ")
t, err := cool.CacheManager.Get(context.Background(), t2)
fmt.Println("后端获取", string(c.Sid), t, err)
if t.Uint32() == c.Handler.UserID {
return true
}
return false
}