Esempio n. 1
0
        static async Task PrintServerStateInVM()
        {
            var    req     = new PlayFab.MultiplayerModels.ListMultiplayerServersRequest();
            string buildID = ReadBuildIDFromInput();
            var    regions = await GetRegions(buildID);

            req.Region  = ReadRegionFromInput(regions);
            req.BuildId = buildID;
            var res = await PlayFabMultiplayerAPI.ListMultiplayerServersAsync(req);

            if (res.Error != null)
            {
                Console.WriteLine(res.Error.ErrorMessage);
            }
            else
            {
                Dictionary <string, Dictionary <string, int> > vmIDsWithStates = new Dictionary <string, Dictionary <string, int> >();
                foreach (var server in res.Result.MultiplayerServerSummaries)
                {
                    if (!vmIDsWithStates.ContainsKey(server.VmId))
                    {
                        vmIDsWithStates.Add(server.VmId, new Dictionary <string, int>());
                    }

                    var statesForVm = vmIDsWithStates[server.VmId];
                    if (!statesForVm.ContainsKey(server.State))
                    {
                        statesForVm.Add(server.State, 0);
                    }

                    statesForVm[server.State]++;
                }

                foreach (var vm in vmIDsWithStates)
                {
                    Console.WriteLine($"- VM with ID:{vm.Key}");
                    foreach (var vmStates in vm.Value)
                    {
                        Console.WriteLine($"    - State:{vmStates.Key}, Count:{vmStates.Value}");
                    }
                }
            }
        }
Esempio n. 2
0
        static async Task ListMultiplayerServers()
        {
            var    req     = new PlayFab.MultiplayerModels.ListMultiplayerServersRequest();
            string buildID = ReadBuildIDFromInput();
            var    regions = await GetRegions(buildID);

            req.Region  = ReadRegionFromInput(regions);
            req.BuildId = buildID;
            var res = await PlayFabMultiplayerAPI.ListMultiplayerServersAsync(req);

            if (res.Error != null)
            {
                Console.WriteLine(res.Error.ErrorMessage);
            }
            else
            {
                PrettyPrintJson(res.Result);
            }
        }