Ejemplo n.º 1
0
        /* Important data */

        public RiotApiClient(string apiKey, string summonerName = null)
        {
            RiotApiUtils.ApiKey       = apiKey;
            RiotApiUtils.SummonerName = summonerName;
            matchClient = new MatchClient();
            userClient  = new UserClient();
        }
    // Use this for initialization
    public void StartOnlineClient(ILogger logger)
    {
        var matchEventHandler = new Match_EventHandler(mM_GUIHandler);
        var data = UnityConfig.GetPersistentDataContainer().persistentData;
        var messageHandlerExpansion = MessageHandlerFactory.CreateMessageHandlerExpansion();
        var config = new UnityClientConfig(InGameWrapper.instance.clockWrapper);

        clientEndPoint = new MatchClient(matchEventHandler, logger, data, messageHandlerExpansion, config);
    }
Ejemplo n.º 3
0
 void Initialize()
 {
     if (_isInit == false)
     {
         lock (_lockRoot)
         {
             if (_isInit == false)
             {
                 _matchClient    = new MatchClient();
                 this._poolMatch = new NBThreadPool(MATCHConcurrency);
                 InitMatchPool();
                 _isInit = true;
             }
         }
     }
 }
Ejemplo n.º 4
0
        public void FillFields(MatchClient client, MatchManager manager)
        {
            nameField.text = client.Name;

            List <MatchPlayer> players = manager.Players.Where(a => a.ClientGuid == client.Guid).ToList();
            int playersTotal           = players.Count();
            int playersReady           = players.Count(a => a.ReadyToRace);

            if (playersTotal == 0)
            {
                playerCountField.text = "Spectating";
            }
            else
            {
                playerCountField.text = playersReady + "/" + playersTotal + " ready";
            }
        }
Ejemplo n.º 5
0
        static async Task Main(string[] args)
        {
            var apiKey = "XXXXX-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
            var uri    = new Uri("https://na1.api.riotgames.com");


            #region Clients code, creates HttpClient client

            var client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            #endregion


            #region Get User Input

            Console.WriteLine("Please enter summoner name:");
            var summonerName = Console.ReadLine();

            #endregion


            #region Get/Deserialize Json to Models

            var uriFactory = new UriFactory(uri.AbsoluteUri, apiKey);

            var summonerClient = new SummonerClient(summonerName, uriFactory, client);
            var summonerModel  = await summonerClient.GetSummonerModelAsync().ConfigureAwait(false);

            var leagueEntryClient = new LeagueEntryClient(summonerModel.Id, uriFactory, client);
            var matchClient       = new MatchClient(summonerModel.AccountId, uriFactory, client);

            var matchListTask   = matchClient.GetMatchListModelAsync();
            var leagueEntryTask = leagueEntryClient.GetLeagueEntryModelsAsync();

            await Task.WhenAll(matchListTask, leagueEntryTask).ConfigureAwait(false);

            var matchListModel = await matchListTask.ConfigureAwait(false);

            var matchId = matchListModel.MostRecentMatchId;

            var timelineClient = new TimelineClient(matchId, client, uriFactory);


            var timelineModel = await timelineClient.GetMatchTimelineModelAsync();

            var leagueEntryModels = await leagueEntryTask.ConfigureAwait(false);

            var matchModel = await matchClient.GetMatchModelAsync(matchListModel.MostRecentMatchId).ConfigureAwait(false);

            var allMatchModels = await matchClient.GetAllMatchModelsAsync().ConfigureAwait(false);

            #endregion


            #region get datadragon information

            var dataDragonClient    = new DataDragonClient(client);
            var championsDictionary = await dataDragonClient.GetChampionsAsync().ConfigureAwait(false);

            #endregion

            #region MatchHistoryViewModel test

            var matchListViewModel = new MatchHistoryViewModel(matchListModel);

            Console.WriteLine("Please enter number of matches you'd like to review.");
            var matchQty = Console.ReadLine();

            if (int.TryParse(matchQty, out int matches))
            {
                Console.WriteLine(matchListViewModel.DisplayMatches(matches, championsDictionary));
            }

            #endregion


            #region Display Output

            //Console.WriteLine();
            //Console.WriteLine(summonerModel.Name);
            //Console.WriteLine(matchListModel.MostRecentMatchId.ToString());
            //Console.WriteLine(matchModel.GameMode);
            //Console.WriteLine(leagueEntryModels[0].Tier);

            //Console.ReadLine();

            #endregion
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Called by MatchClients whose owners left the game, this removes the MatchClient from the list of match clients.
 /// </summary>
 public void RemoveMatchClient(MatchClient clientRemoving)
 {
     clients.Remove(clientRemoving);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Called by new MatchClients, this adds the MatchClient to the list of match clients.
 /// </summary>
 public void AddMatchClient(MatchClient clientAdding)
 {
     clients.Add(clientAdding);
 }