修复在线玩家

This commit is contained in:
wh_zcy 2023-03-16 18:13:20 +08:00
parent 457ed31fff
commit d3f0f0aada
2 changed files with 42 additions and 28 deletions

View File

@ -45,12 +45,19 @@ func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
// 设置用户session // 设置用户session
func (this *ModelSession) addUserSession(uid string, session comm.IUserSession) (err error) { func (this *ModelSession) addUserSession(uid string, session comm.IUserSession) (err error) {
if err = this.AddList(comm.RDS_EMPTY, uid, map[string]interface{}{ // if err = this.AddList(comm.RDS_EMPTY, uid, map[string]interface{}{
"uid": uid, // "uid": uid,
"sessionId": session.GetSessionId(), // "sessionId": session.GetSessionId(),
"serviceTag": session.GetServiecTag(), // "serviceTag": session.GetServiecTag(),
"gatewayServiceId": session.GetGatewayServiceId(), // "gatewayServiceId": session.GetGatewayServiceId(),
"ip": session.GetIP(), // "ip": session.GetIP(),
// }, db.SetDBMgoLog(false)); err != nil {
if err = this.AddList(comm.RDS_EMPTY, uid, &pb.CacheUser{
Uid: uid,
SessionId: session.GetSessionId(),
ServiceTag: session.GetServiecTag(),
GatewayServiceId: session.GetGatewayServiceId(),
Ip: session.GetIP(),
}, db.SetDBMgoLog(false)); err != nil { }, db.SetDBMgoLog(false)); err != nil {
log.Debug("setUserSession err:%v", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err}) log.Debug("setUserSession err:%v", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err})
return return

View File

@ -196,12 +196,19 @@ func (this *SCompGateRoute) NoticeUserLogin(ctx context.Context, args *pb.Notice
return err return err
} }
model := db.NewDBModel(comm.TableSession, 0, conn) model := db.NewDBModel(comm.TableSession, 0, conn)
model.AddList(comm.RDS_EMPTY, args.UserId, map[string]interface{}{ // model.AddList(comm.RDS_EMPTY, args.UserId, map[string]interface{}{
"uid": args.UserId, // "uid": args.UserId,
"sessionId": args.UserSessionId, // "sessionId": args.UserSessionId,
"serviceTag": args.ServiceTag, // "serviceTag": args.ServiceTag,
"gatewayServiceId": args.GatewayServiceId, // "gatewayServiceId": args.GatewayServiceId,
"ip": args.Ip, // "ip": args.Ip,
// }, db.SetDBMgoLog(false))
model.AddList(comm.RDS_EMPTY, args.UserId, &pb.CacheUser{
Uid: args.UserId,
SessionId: args.UserSessionId,
ServiceTag: args.ServiceTag,
GatewayServiceId: args.GatewayServiceId,
Ip: args.Ip,
}, db.SetDBMgoLog(false)) }, db.SetDBMgoLog(false))
session := this.pools.Get().(comm.IUserSession) session := this.pools.Get().(comm.IUserSession)
session.SetSession(args.Ip, args.UserSessionId, args.ServiceTag, args.GatewayServiceId, args.UserId) session.SetSession(args.Ip, args.UserSessionId, args.ServiceTag, args.GatewayServiceId, args.UserId)