//根据userId查询User public static async Task <User> Query(this UserComponent userComponent, long userId) { User userInId = userComponent.GetUser(userId); if (userInId != null) { return(userInId); } List <User> userList = await userComponent.dbProxyComponent.Query <User>(user => user.UserId == userId); if (userList.Count > 0) { return(userList[0]); } return(null); }
//玩家上线事件 public static async Task <User> UserOnLine(this UserComponent userComponent, long userId, long sessionActorId) { User user = userComponent.GetUser(userId); if (user != null) { user.ByCompelAccount(); user.GetComponent <UserGateActorIdComponent>().ActorId = sessionActorId; return(user);//如果User本就在线 发送强制下线消息 就改变一下actorid } user = await userComponent.Query(userId); if (user != null) { user.AddComponent <UserGateActorIdComponent>().ActorId = sessionActorId; userComponent.mOnlineUserDic[user.UserId] = user; user.IsOnLine = true; } return(user); }