上传会话对象绑定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
func (this *UserSession) Bind(uid string, wokerId string) (err error) {
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,
UserId: uid,
WorkerId: wokerId,
}, reply); err != nil {
log.Errorf("Bind UserSession:%s UserId:%s err:%v", this.SessionId, this.UserId, err)
return
}
this.UserId = uid
return
}
//解绑uid 注销和切换账号是处理
func (this *UserSession) UnBind() (err error) {
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,
}, reply); err != nil {
log.Errorf("UnBuild UserSession:%s UserId:%s err:%v", this.SessionId, this.UserId, err)
return
}
this.UserId = ""
return
}