diff --git a/comm/usersession.go b/comm/usersession.go index 82fc50420..ddcec3825 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -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 }