上传会话对象绑定uid

This commit is contained in:
liwei1dao 2022-06-28 19:07:28 +08:00
parent eec7fd58f3
commit 92ee1d454d

View File

@ -66,24 +66,28 @@ func (this *UserSession) IsLogin() bool {
///wokerId 用户绑定worker服务id ///wokerId 用户绑定worker服务id
func (this *UserSession) Bind(uid string, wokerId string) (err error) { func (this *UserSession) Bind(uid string, wokerId string) (err error) {
reply := &pb.RPCMessageReply{} reply := &pb.RPCMessageReply{}
if err := this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentBind), &pb.AgentBuildReq{ if err = this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentBind), &pb.AgentBuildReq{
UserSessionId: this.SessionId, UserSessionId: this.SessionId,
UserId: uid, UserId: uid,
WorkerId: wokerId, WorkerId: wokerId,
}, reply); err != nil { }, reply); err != nil {
log.Errorf("Bind UserSession:%s UserId:%s err:%v", this.SessionId, this.UserId, err) log.Errorf("Bind UserSession:%s UserId:%s err:%v", this.SessionId, this.UserId, err)
return
} }
this.UserId = uid
return return
} }
//解绑uid 注销和切换账号是处理 //解绑uid 注销和切换账号是处理
func (this *UserSession) UnBind() (err error) { func (this *UserSession) UnBind() (err error) {
reply := &pb.RPCMessageReply{} reply := &pb.RPCMessageReply{}
if err := this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentUnBind), &pb.AgentUnBuildReq{ if err = this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentUnBind), &pb.AgentUnBuildReq{
UserSessionId: this.SessionId, UserSessionId: this.SessionId,
}, reply); err != nil { }, reply); err != nil {
log.Errorf("UnBuild UserSession:%s UserId:%s err:%v", this.SessionId, this.UserId, err) log.Errorf("UnBuild UserSession:%s UserId:%s err:%v", this.SessionId, this.UserId, err)
return
} }
this.UserId = ""
return return
} }