public async Task <List <RedisRoomModel> > GetActiveRooms()
        {
            List <RedisRoomModel> userGames = new List <RedisRoomModel>();

            if (this.HasClaim(UserClaim.Admin))
            {
                // Admins can see every room.
                HashEntry[] games = await RedisConnector.Redis.HashGetAllAsync("games");

                foreach (var game in games)
                {
                    userGames.Add(new RedisRoomModel(game.Value));
                }

                return(userGames);
            }

            RedisValue[] roomIds = await RedisConnector.Redis.SetMembersAsync($"users:{UserModel.Id}:games");

            foreach (var roomId in roomIds)
            {
                userGames.Add(await RedisRoomModel.GetRoomFromGuid(roomId));
            }
            return(userGames);
        }
Пример #2
0
 public GroupChatModel(RedisRoomModel roomModel, RedisValue groupChat)
 {
     RoomModel    = roomModel;
     MessageGroup = GroupModel.Parser.ParseFrom(groupChat);
 }