protected override async void Run(Session session, C2F_GetMemberList message, Action <F2C_GetMemberList> reply) { F2C_GetMemberList response = new F2C_GetMemberList(); try { FriendsCircle friendsCircle = await FriendsCircleComponent.Ins.QueryFriendsCircle(message.FriendsCrircleId); if (friendsCircle == null) { response.Message = "亲友圈不存在"; reply(response); return; } if (!friendsCircle.ManageUserIds.Contains(message.UserId)) { response.Message = "管理权限不足"; reply(response); return; } FriendsCirleMemberInfo memberInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleMember(message.FriendsCrircleId); response.MemberUserIdList = memberInfo.MemberList; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
//玩家退出亲友圈 被管理踢 或者自己退都走这 public static async void SucceedOutriendsCircle(this FriendsCircle friendsCircle, long userId) { if (friendsCircle.CreateUserId == userId) { return; } UserInFriendsCircle userInFriendsCircle = await FriendsCircleComponent.Ins.QueryUserInFriendsCircle(userId); if (userInFriendsCircle.FriendsCircleIdList.Contains(friendsCircle.FriendsCircleId)) { userInFriendsCircle.FriendsCircleIdList.Remove(friendsCircle.FriendsCircleId); } await FriendsCircleComponent.Ins.SaveDB(userInFriendsCircle); FriendsCirleMemberInfo friendsCirleMemberInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleMember(friendsCircle.FriendsCircleId); if (friendsCirleMemberInfo.MemberList.Contains(userId)) { friendsCirleMemberInfo.MemberList.Remove(userId); } await FriendsCircleComponent.Ins.SaveDB(friendsCirleMemberInfo); friendsCircle.TotalNumber--; await FriendsCircleComponent.Ins.SaveDB(friendsCircle); }
public static FriendsCirleMemberInfo Create(int friendsCirleId) { FriendsCirleMemberInfo friendsCirleMemberInfo = ComponentFactory.Create <FriendsCirleMemberInfo>(); friendsCirleMemberInfo.FriendsCircleId = friendsCirleId; return(friendsCirleMemberInfo); }
//玩家成功加入亲友圈 public static async Task SucceedJoinFriendsCircle(this FriendsCircle friendsCircle, long userId) { UserInFriendsCircle userInFriendsCircle = await FriendsCircleComponent.Ins.QueryUserInFriendsCircle(userId); userInFriendsCircle.FriendsCircleIdList.Add(friendsCircle.FriendsCircleId); await FriendsCircleComponent.Ins.SaveDB(userInFriendsCircle); FriendsCirleMemberInfo friendsCirleMemberInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleMember(friendsCircle.FriendsCircleId); friendsCirleMemberInfo.MemberList.Add(userId); await FriendsCircleComponent.Ins.SaveDB(friendsCirleMemberInfo); friendsCircle.TotalNumber++; await FriendsCircleComponent.Ins.SaveDB(friendsCircle); }
//把人踢出亲友圈 public static async Task KickOutFriendsCircle(this FriendsCircle friendsCircle, long operateUserId, long byOperateUserId, IResponse iResponse) { if (friendsCircle.ManageUserIds.Contains(byOperateUserId)) { iResponse.Message = "不能踢管理出亲友圈"; return; } FriendsCirleMemberInfo applyFriendsCirleInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleMember(friendsCircle.FriendsCircleId); if (!applyFriendsCirleInfo.MemberList.Contains(byOperateUserId)) { iResponse.Message = "玩家已经不再亲友圈中"; return; } friendsCircle.SucceedOutriendsCircle(byOperateUserId);//成功退出亲友圈 }
//申请加入亲友圈 public static async Task ApplyJoinFriendsCircle(this FriendsCircle friendsCircle, long userId, IResponse iResponse) { FriendsCirleMemberInfo memberInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleMember(friendsCircle.FriendsCircleId); if (memberInfo.MemberList.Contains(userId)) { iResponse.Message = "你已经在该亲友圈中"; return; } ApplyFriendsCirleInfo applyFriendsCirleInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleApply(friendsCircle.FriendsCircleId); if (applyFriendsCirleInfo.ApplyList.Contains(userId)) { iResponse.Message = "已经在申请列表中"; return; } applyFriendsCirleInfo.ApplyList.Add(userId); await FriendsCircleComponent.Ins.SaveDB(applyFriendsCirleInfo); }
//获取亲友圈的成员列表 public static async Task <RepeatedField <long> > GetMemberList(this FriendsCircle friendsCircle) { FriendsCirleMemberInfo friendsCirleMemberInfo = await FriendsCircleComponent.Ins.QueryFriendsCircleMember(friendsCircle.FriendsCircleId); return(friendsCirleMemberInfo.MemberList); }