public async Task <BodyResponse <NullBody> > Handle(RecieveMsgReward request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "Msgs", MsgTypes.Reward.ToString()))) { await locker.LockAsync(); var msg = await _redis.GetMsgInfo(request.Id, MsgTypes.Reward, request.MsgId); if (msg != null && msg.MsgState != MsgStates.Recieved) { List <Task> tasks = new List <Task>(); foreach (var one in msg.RewardInfo) { var rewardMethod = one.GenRewardMethod(one.RewardType); if (rewardMethod == null) { continue; } tasks.Add(rewardMethod.AddReward(_mqBus, request.Id, one)); } await Task.WhenAll(tasks); msg.MsgState = MsgStates.Recieved; await _redis.SetMsgInfo(request.Id, MsgTypes.Reward, msg); } return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public async Task <BodyResponse <List <RewardInfo> > > Handle(RecieveAllMsgRewardCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "Msgs", MsgTypes.Reward.ToString()))) { await locker.LockAsync(); var msgs = await _redis.GetAllMsg(request.Id, MsgTypes.Reward); List <Task> tasks = new List <Task>(); List <RewardInfo> allreward = new List <RewardInfo>(); foreach (var one in msgs) { if (one.Value.MsgState != MsgStates.Recieved) { foreach (var oneRward in one.Value.RewardInfo) { var rewardMethod = oneRward.GenRewardMethod(oneRward.RewardType); if (rewardMethod == null) { continue; } allreward.Add(oneRward); tasks.Add(rewardMethod.AddReward(_mqBus, request.Id, oneRward)); } } one.Value.MsgState = MsgStates.Recieved; tasks.Add(_redis.SetMsgInfo(request.Id, MsgTypes.Reward, one.Value)); } await Task.WhenAll(tasks); return(new BodyResponse <List <RewardInfo> >(StatusCodeDefines.Success, null, allreward)); } }
public async Task AddPlatformFriend(string platformAccount, int type, FriendInfo friendInfo) { //查询该玩家是否是注册玩家 var response = await _mqGetIdCleint.GetResponseExt <GetIdByPlatformMqCommand, BodyResponse <GetIdByPlatformMqResponse> > (new GetIdByPlatformMqCommand(platformAccount, type)); if (response.Message.StatusCode != StatusCodeDefines.Success) { return; } long friendId = response.Message.Body.Id; if (friendInfo._friends == null || !friendInfo._friends.TryGetValue(friendId, out var info)) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(friendId, "FriendInfo"))) { await AddFriend(friendInfo.Id, friendId, FriendTypes.PlatformFriend); return; } } if (info.Type != FriendTypes.PlatformFriend) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(friendId, "FriendInfo"))) { await _redis.DeleteFriend(friendInfo.Id, friendId); await Task.WhenAll(_redis.AddFriend(friendInfo.Id, friendId, FriendTypes.PlatformFriend), _friendRepository.UpdateFriend(friendInfo.Id, friendId, FriendTypes.PlatformFriend)); } } }
public async Task <BodyResponse <RewardInfoVM> > Handle(GetGameActRewardCommand request, CancellationToken cancellationToken) { DateTime tnow = DateTime.Now; var roomConfig = _activityConfig.AllGameConfigs .Find(x => x.ActivityId == request.ActId).RoomConfigs .Find(x => x.SubId == request.SubId); using (var locker = _redis.Locker(KeyGenHelper.GenUserDayKey(tnow, request.Id, "GameActivity", request.ActId))) { await locker.LockAsync(); var subAct = await _redis.GetGameActProgress(tnow, request.Id, request.ActId, request.SubId); long rewardCoins = 0; if (subAct.State == 1) { return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.Error)); } if (subAct.CurCount >= roomConfig.NeedCount) { rewardCoins = roomConfig.RewardCoins; _ = _mqBus.Publish(new AddMoneyMqCommand(request.Id, rewardCoins, 0, AddReason.GameAct)); subAct.State = 1; await _redis.SetGameActProgress(tnow, request.Id, request.ActId, request.SubId, subAct); return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.Success, null, new RewardInfoVM(rewardCoins))); } else { return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.Error)); } } }
public async Task <OneGameActivityInfo> GetGameActivity(DateTime time, long id, string activityId) { Dictionary <string, GameSubActInfo> dic = await _redis.GetHashAllAsync <string, GameSubActInfo> (KeyGenHelper.GenUserDayKey(time, id, "GameActivity", activityId)); return(new OneGameActivityInfo(activityId, dic)); }
public async Task <BodyResponse <RewardInfoVM> > Handle(GetLoginRewardCommand request, CancellationToken cancellationToken) { DateTime tnow = DateTime.Now; int dayOfWeek = (int)tnow.DayOfWeek; using (var locker = _redis.Locker(KeyGenHelper.GenUserWeekKey(tnow, request.Id, LoginRewardInfo.className))) { var rewardInfo = await _redis.GetLoginReward(tnow, request.Id); long rewardCoins = 0; if (rewardInfo == null || !rewardInfo.GettedDays.Contains(dayOfWeek)) { rewardCoins = _loginConfig.DayRewards[dayOfWeek]; if (rewardInfo == null) { rewardInfo = new LoginRewardInfo(request.Id, new List <int>()); } rewardInfo.GettedDays.Add(dayOfWeek); await _redis.SetUserLoginReward(tnow, rewardInfo); _ = _mqBus.Publish(new AddMoneyMqCommand(request.Id, rewardCoins, 0, AddReason.LoginReward)); } else { return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.RewardGetted)); } return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.Success, null, new RewardInfoVM(rewardCoins))); } }
public Task AddMsgInfo(long id, MsgTypes msgType, UserMsgInfo info) { return(Task.WhenAll(_redis.AddZsetValueAsync(KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString()), info.MsgId, DateTime.Now.ToTimeStamp(), TimeSpan.FromDays(30)), _redis.AddHashValueAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), info.MsgId, info, TimeSpan.FromDays(30)), DeleteExpiredMsgs(id, msgType))); }
public async Task <BodyResponse <GetFriendInfoMqResponse> > Handle(GetFriendInfoCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "FriendInfo"))) { await LoadToRedis(request.Id); var info = await _redis.GetOneFriendInfo(request.Id, request.OtherId); if (info != null) { return(new BodyResponse <GetFriendInfoMqResponse>(StatusCodeDefines.Success, null, new GetFriendInfoMqResponse(info.Type))); } if (await _redis.IsAlreadyApplyed(request.Id, request.OtherId)) { return(new BodyResponse <GetFriendInfoMqResponse>(StatusCodeDefines.Success, null, new GetFriendInfoMqResponse(FriendTypes.Applyed))); } else { return(new BodyResponse <GetFriendInfoMqResponse>(StatusCodeDefines.Success, null, new GetFriendInfoMqResponse(FriendTypes.None))); } } }
public async Task <FriendInfo> GetFriendInfo(long id) { FriendInfo info = new FriendInfo(id, await _redis.GetHashAllAsync <long, OneFriendInfo> (KeyGenHelper.GenUserKey(id, "FriendInfo"))); return(info); }
public async Task <BodyResponse <LevelInfo> > Handle(GetLevelInfoCommand request, CancellationToken cancellationToken) { //读取redis account信息 LevelInfo levelinfo = await _redis.GetLevelInfo(request.Id); if (levelinfo == null) { //从数据库中获取 using (var loker = _redis.Locker(KeyGenHelper .GenUserKey(request.Id, LevelInfo.ClassName))) { loker.Lock(); levelinfo = await _levelRepository.FindAndAdd(request.Id, new LevelInfo(request.Id, 1, 0, _levelManager.GetNeedExp(1))); _ = _redis.SetLevelInfo(levelinfo); } } BodyResponse <LevelInfo> response = new BodyResponse <LevelInfo>(StatusCodeDefines.Success, null, levelinfo); return(response); }
public async Task <BodyResponse <NullBody> > Handle(AgreeAddFriendCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "FriendInfo"))) using (var lockerFriend = _redis.Locker(KeyGenHelper.GenUserKey(request.FriendId, "FriendInfo"))) { await Task.WhenAll(locker.LockAsync(), lockerFriend.LockAsync()); var infos = await LoadToRedis(request.Id, request.FriendId); bool isFriend = false; if (infos[0] != null && infos[0]._friends.ContainsKey(request.FriendId)) { isFriend = true; } if (isFriend) { return(new BodyResponse <NullBody>(StatusCodeDefines.IsAlreadyFriend)); } bool isApplyed = await _redis.IsAlreadyApplyed(request.FriendId, request.Id); if (!isApplyed) { return(new BodyResponse <NullBody>(StatusCodeDefines.IsNotApplyed)); } await AddFriend(request.Id, request.FriendId, 0); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public async Task <List <long> > GetInviter(string platform, int type) { var allInviter = await _redis.GetZsetAllKeyAsync(KeyGenHelper.GenKey (platform, "Invited")); return(allInviter.ConvertAll <long>(x => Convert.ToInt64(x))); }
public Task AddApplyedFriend(long id, long friendId) { return(Task.WhenAll(_redis.AddZsetValueAsync(KeyGenHelper.GenUserKey(id, "ApplyedFriendInfo"), friendId.ToString(), DateTime.Now.ToTimeStamp(), TimeSpan.FromDays(30)), _redis.DeleteZsetValueRangeAsync( KeyGenHelper.GenUserKey(id, "ApplyedFriendInfo"), 0, DateTime.Now.ToTimeStamp() - TimeSpan.FromDays(30).TotalSeconds))); }
public async Task <BodyResponse <MoneyInfo> > Handle(GetMoneyCommand request, CancellationToken cancellationToken) { var moneyInfo = await _redis.GetMoney(request.Id); if (moneyInfo == null) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, MoneyInfo.ClassName))) { await locker.LockAsync(); moneyInfo = await _moneyRepository.FindAndAdd(request.Id, new MoneyInfo(request.Id, 0, 0, 0, 0, 0)); _ = _redis.SetMoney(request.Id, moneyInfo); } if (moneyInfo == null) { return(new BodyResponse <MoneyInfo>(StatusCodeDefines.GetMoneyError, null, null)); } } BodyResponse <MoneyInfo> response = new BodyResponse <MoneyInfo> (StatusCodeDefines.Success, null, moneyInfo); Log.Debug($"GetMoneyCommand:{moneyInfo.CurCoins},{moneyInfo.Carry}"); return(response); }
public Task SetLoginCheckInfo(string account, AccountInfo info) { _redis.SetStringNoWait <LoginCheckInfo>(KeyGenHelper.GenKey(account, typeof(LoginCheckInfo).Name), new LoginCheckInfo(info.Id, info.PlatformAccount, info.Type), TimeSpan.FromDays(7)); return(Task.CompletedTask); }
public async Task <GameSubActInfo> GetGameActProgress(DateTime time, long id, string activityId, string subId) { GameSubActInfo subAct = await _redis.GetHashValueAsync <GameSubActInfo> (KeyGenHelper.GenUserDayKey(time, id, "GameActivity", activityId), subId); return(subAct); }
public async Task <BodyResponse <NullBody> > OnUserApplySit(long id, string gameKey, Int64 blind, string roomId) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(id, UserRoomInfo.className))) { await locker.LockAsync(); var userRoomInfo = await _redis.GetUserRoomInfo(id); if (userRoomInfo != null) { return(new BodyResponse <NullBody>(StatusCodeDefines.Error, new List <string>() { "user already in room " })); } if (!_roomManager.JoinOneRoom(gameKey, roomId)) { return(new BodyResponse <NullBody>(StatusCodeDefines.Error, new List <string>() { "room is full " })); } _ = _redis.SetUserRoomInfo(new UserRoomInfo(id, roomId, gameKey, blind, MatchingStatus.Success)); return(new BodyResponse <NullBody>(StatusCodeDefines.Success, null)); } }
public async Task <BodyResponse <RewardInfoVM> > Handle(GetBankruptcyRewardCommand request, CancellationToken cancellationToken) { DateTime tnow = DateTime.Now; using (var locker = _redis.Locker(KeyGenHelper.GenUserDayKey(tnow, request.Id, BankruptcyInfo.className))) { await locker.LockAsync(); var bankruptcyInfo = await _redis.GetBankruptcyInfo(tnow, request.Id); int totalTimes = _bankruptcyConfig.BankruptcyRewards.Count; if (bankruptcyInfo == null) { bankruptcyInfo = new BankruptcyInfo(0); } if (bankruptcyInfo.CurTimes >= 2) { return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.RewardNotAvailable)); } long rewardCoins = _bankruptcyConfig.BankruptcyRewards[bankruptcyInfo.CurTimes]; ++bankruptcyInfo.CurTimes; await _redis.SetBankruptcyInfo(tnow, bankruptcyInfo); _ = _mqBus.Publish(new AddMoneyMqCommand(request.Id, rewardCoins, 0, AddReason.Bankruptcy)); return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.Success, null, new RewardInfoVM(rewardCoins))); } }
public async Task DeleteExpiredMsgs(long id, MsgTypes msgType) { string key = KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString()); var deletedKeys = await _redis.DeleteZsetReturnValueRangeAsync (key, 0, (DateTime.Now - TimeSpan.FromDays(30)).ToTimeStamp()); await _redis.DeleteHashValuesAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), deletedKeys); }
public async Task <BodyResponse <NullBody> > Handle(DeleteMsgCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "Msgs", MsgTypes.Reward.ToString()))) { await _redis.DeleteMsg(request.Id, request.MsgType, request.MsgId); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public async Task <BodyResponse <GameSampleMatchingResponseInfo> > MatchingRoom(long id, long blind, string curRoomId) { //获取这个玩家的redis锁 using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(id, UserRoomInfo.className))) { if (!await locker.TryLockAsync()) { return(new BodyResponse <GameSampleMatchingResponseInfo>(StatusCodeDefines.IsMatching, null, null)); } //查询redis是否有这个玩家 RoomInfo roomInfo = null; var userRoomInfo = await _redis.GetUserRoomInfo(id); if (userRoomInfo != null) { roomInfo = new RoomInfo(userRoomInfo.RoomId, 0, userRoomInfo.GameKey, userRoomInfo.Blind); } else { roomInfo = await _roomManager.GetRoom(id, blind); } try { BodyResponse <JoinGameRoomMqResponse> roomResponse = await _roomManager.SendToGameRoom <JoinGameRoomMqCommand, BodyResponse <JoinGameRoomMqResponse> > (roomInfo.GameKey, new JoinGameRoomMqCommand(id, roomInfo.RoomId, roomInfo.GameKey)); if (roomResponse.StatusCode == StatusCodeDefines.Success) { _ = _redis.SetUserRoomInfo(new UserRoomInfo(id, roomInfo.RoomId, roomInfo.GameKey, blind, MatchingStatus.Success)); return(new BodyResponse <GameSampleMatchingResponseInfo>(StatusCodeDefines.Success, null, new GameSampleMatchingResponseInfo(id, roomInfo.RoomId, roomInfo.Blind, roomInfo.GameKey))); } else { if (roomResponse.Body != null) { RoomInfo newRoomInfo = new RoomInfo(roomResponse.Body.RoomId, roomResponse.Body.UserCount, roomResponse.Body.GameKey, roomResponse.Body.Blind); _roomManager.UpdateRoom(newRoomInfo); } _ = _redis.DeleteUserRoomInfo(id); return(new BodyResponse <GameSampleMatchingResponseInfo>(roomResponse.StatusCode, roomResponse.ErrorInfos, null)); } } catch { _ = _redis.DeleteUserRoomInfo(id); Log.Error($"user {id} join room {roomInfo.RoomId} error"); return(new BodyResponse <GameSampleMatchingResponseInfo>(StatusCodeDefines.BusError, null, null)); } } }
public async Task <BodyResponse <NullBody> > Handle(IgnoreApplyCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "FriendInfo"))) using (var lockerFriend = _redis.Locker(KeyGenHelper.GenUserKey(request.FriendId, "FriendInfo"))) { await _redis.IgnoreApply(request.Id, request.FriendId); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public async Task <BodyResponse <NullBody> > Handle(DeleteFriendCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "FriendInfo"))) using (var lockerFriend = _redis.Locker(KeyGenHelper.GenUserKey(request.FriendId, "FriendInfo"))) { await Task.WhenAll(_redis.DeleteFriend(request.Id, request.FriendId), _friendRepository.DeleteFriend(request.Id, request.FriendId)); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public async Task <BodyResponse <MoneyMqResponse> > Handle(AddMoneyCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, MoneyInfo.ClassName))) { await locker.LockAsync(); Log.Debug($"AddMoneyCommand add begin:{request.AddCoins},{request.AddCarry} {request.AggregateId}"); var moneyInfo = await _redis.GetMoney(request.Id); if (moneyInfo == null) { moneyInfo = await _moneyRepository.FindAndAdd(request.Id, new MoneyInfo(request.Id, 0, 0, 0, 0, 0)); } if (request.AddCoins < 0 && System.Math.Abs(request.AddCoins) > moneyInfo.CurCoins) { Log.Debug($"AddMoneyCommand add end:{request.AddCoins},{request.AddCarry} {request.AggregateId}--1"); return(new BodyResponse <MoneyMqResponse> (StatusCodeDefines.NoEnoughMoney, null, null)); } if (request.AddCarry < 0 && System.Math.Abs(request.AddCarry) > moneyInfo.Carry) { Log.Debug($"AddMoneyCommand add end:{request.AddCoins},{request.AddCarry} {request.AggregateId}--2"); return(new BodyResponse <MoneyMqResponse> (StatusCodeDefines.NoEnoughMoney, null, null)); } moneyInfo.AddCoins(request.AddCoins); moneyInfo.AddCarry(request.AddCarry); moneyInfo.UpdateMaxCoins(); long coinsChangedCount = request.AddCoins + request.AddCarry; var moneyevent = new MoneyChangedMqEvent (moneyInfo.Id, moneyInfo.CurCoins, moneyInfo.CurDiamonds, moneyInfo.MaxCoins, moneyInfo.MaxDiamonds, coinsChangedCount, 0); _busCtl.PublishExt(moneyevent); _busCtl.PublishServerReqExt(moneyInfo.Id, moneyevent); await Task.WhenAll(_redis.SetMoney(request.Id, moneyInfo), _moneyRepository.ReplaceAsync(moneyInfo)); Log.Debug($"AddMoneyCommand add end:{request.AddCoins},{request.AddCarry} {request.AggregateId} curCoins:{moneyInfo.CurCoins} curCarry:{moneyInfo.Carry}--3"); return(new BodyResponse <MoneyMqResponse>(StatusCodeDefines.Success, null, new MoneyMqResponse(request.Id, moneyInfo.CurCoins, moneyInfo.CurDiamonds, moneyInfo.MaxCoins, moneyInfo.MaxDiamonds, moneyInfo.Carry))); } }
public async Task <BodyResponse <NullBody> > Handle(ReadedAllCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "Msgs", request.MsgType.ToString()))) { await locker.LockAsync(); await _redis.ReadedAllMsg(request.Id, request.MsgType); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public Task RemovInviteFriend(List <long> allInviter, string platform, int type) { List <Task> allTasks = new List <Task>(); allTasks.Add(_redis.DeleteKeyAsync(KeyGenHelper.GenKey (platform, "Invited"))); foreach (var oneInviter in allInviter) { allTasks.Add(_redis.DeleteZsetValueAsync(KeyGenHelper.GenUserKey (oneInviter, "Inviter"), platform)); } return(Task.WhenAll(allTasks)); }
public async Task <BodyResponse <NullBody> > Handle(ApplyAddFriendCommand request, CancellationToken cancellationToken) { using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(request.Id, "FriendInfo"))) using (var lockerFriend = _redis.Locker(KeyGenHelper.GenUserKey(request.FriendId, "FriendInfo"))) { await Task.WhenAll(locker.LockAsync(), lockerFriend.LockAsync()); var infos = await LoadToRedis(request.Id, request.FriendId); var selfInfo = infos[0]; var friendInfo = infos[1]; bool isFriend = friendInfo._friends.ContainsKey(request.FriendId); if (isFriend) { return(new BodyResponse <NullBody>(StatusCodeDefines.IsAlreadyFriend)); } bool isApplyed = await _redis.IsAlreadyApplyed(request.FriendId, request.Id); if (isApplyed) { bool isApplyedEachOther = await _redis.IsAlreadyApplyed(request.Id, request.FriendId); if (isApplyedEachOther) { await AddFriend(request.FriendId, request.Id, 0); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } return(new BodyResponse <NullBody>(StatusCodeDefines.IsAlreadyApplyed)); } List <Task <long> > tFrindCounts = new List <Task <long> > { _redis.GetApplyedFriendCount(request.FriendId), _redis.GetFriendCount(request.FriendId), _redis.GetFriendCount(request.Id) }; await Task.WhenAll(tFrindCounts); if (tFrindCounts.Where(x => x.Result >= 1000).Count() > 0) { return(new BodyResponse <NullBody>(StatusCodeDefines.IsFull)); } await _redis.AddApplyedFriend(request.FriendId, request.Id); _mqBus.PublishServerReqExt(request.FriendId, new ApplyedAddFriendMqEvent(request.Id)); return(new BodyResponse <NullBody>(StatusCodeDefines.Success)); } }
public async Task AddFriend(long id, long friendId, FriendTypes type) { await Task.WhenAll(_redis.AddHashValueAsync(KeyGenHelper.GenUserKey(id, "FriendInfo"), friendId.ToString(), new OneFriendInfo(friendId, type)), _redis.DeleteSetValueAsync(KeyGenHelper.GenUserKey(id, "ApplyedFriendInfo"), friendId.ToString()), _redis.DeleteSetValueAsync(KeyGenHelper.GenUserKey(friendId, "ApplyedFriendInfo"), friendId.ToString()), _redis.AddHashValueAsync(KeyGenHelper.GenUserKey(friendId, "FriendInfo"), id.ToString(), new OneFriendInfo(id, type))); }
public Task SetFriendInfo(FriendInfo info) { if (info == null || info._friends.Count == 0) { //如果好友为空,插一条数据进去,写入redis,这样可以防止redis没数据,每次都从数据库读取 var dic = new Dictionary <long, OneFriendInfo>() { { -1, new OneFriendInfo(-1, FriendTypes.None) } }; return(_redis.AddHashListAsync(KeyGenHelper.GenUserKey(info.Id, "FriendInfo"), dic, TimeSpan.FromDays(7))); } return(Task.WhenAll(_redis.AddHashListAsync(KeyGenHelper.GenUserKey(info.Id, "FriendInfo"), info._friends, TimeSpan.FromDays(7)))); }
public async Task OnSiteFailed(long id, string gameKey, string roomId, string group) { if (group != matchingGroup) { return; } using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(id, UserRoomInfo.className))) { await locker.LockAsync(); _ = _redis.DeleteUserRoomInfo(id); _roomManager.JoinOneRoomFailed(gameKey, roomId); } }