Files
bl/logic/service/login/LoginSidInfo.go

35 lines
960 B
Go
Raw Normal View History

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
}