```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
@@ -3,8 +3,13 @@ package controller
|
||||
import (
|
||||
"blazing/common/rpc"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/user"
|
||||
"blazing/modules/base/service"
|
||||
playerservice "blazing/modules/player/service"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
@@ -21,12 +26,37 @@ import (
|
||||
// GetServerOnline 处理命令: 105
|
||||
func (h Controller) GetServerOnline(data *user.SidInfo, c gnet.Conn) (result *rpc.CommendSvrInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
result = rpc.NewInInfo()
|
||||
// tt, _ := cool.CacheManager.Keys(context.Background())
|
||||
//g.Dump(tt)
|
||||
t1 := hex.EncodeToString(data.Sid)
|
||||
userid, ok := playerservice.User.Load(t1)
|
||||
if !ok || userid != data.Head.UserID {
|
||||
|
||||
defer c.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// if service.NewBaseSysUserService().GetPerson(data.Head.UserID).Debug == 1 {
|
||||
// result.IsVip = 1
|
||||
// }
|
||||
result.IsVip = 1
|
||||
result.ServerList = rpc.GetServerInfoList(service.NewBaseSysUserService().GetPerson(data.Head.UserID).Debug)
|
||||
defer func() {
|
||||
|
||||
// share.ShareManager.DeleteSession(t1)
|
||||
|
||||
ser := playerservice.NewUserService(data.Head.UserID)
|
||||
kickErr := ser.Info.Kick(data.Head.UserID)
|
||||
if kickErr != nil {
|
||||
fmt.Println("踢人失败", kickErr)
|
||||
|
||||
}
|
||||
logininfo := ser.Info.SetLogin()
|
||||
if logininfo != nil {
|
||||
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player: %d", data.Head.UserID), logininfo, 0)
|
||||
cool.CacheManager.Set(context.Background(), fmt.Sprintf("session: %d", data.Head.UserID), t1, 0)
|
||||
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
return
|
||||
|
||||
//return //TODO 这里待实现改成接口调用Ret方法
|
||||
|
||||
Reference in New Issue
Block a user