Example #1
0
        public void OneTimeSetUp()
        {
            var channel = new Channel(AuthServerTarget, ChannelCredentials.Insecure);

            _authServiceClient      = new AuthService.AuthServiceClient(channel);
            PlayFabSettings.TitleId = PlayFabTitleId;
        }
Example #2
0
        public CreateNewUser()
        {
            InitializeComponent();
            try
            {
                ViewModel   = LayoutRoot.DataContext as CreateNewUserViewModel;
                DataContext = ViewModel;
            }
            catch { }
            ClearControls();
            LoadData();
            IsValidUserName = false;

            AuthService.AuthServiceClient c = new AuthService.AuthServiceClient();
        }
Example #3
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <SampleClientArguments>(args)
            .WithParsed(parsedArgs =>
            {
                var gatewayServiceUrl = parsedArgs.Local
                        ? string.Format(LocalEndPointUrlFormat, "4040")
                        : string.Format(CloudEndPointUrlFormat, "gateway", parsedArgs.GoogleProject);

                var partyServiceUrl = parsedArgs.Local
                        ? string.Format(LocalEndPointUrlFormat, "4041")
                        : string.Format(CloudEndPointUrlFormat, "party", parsedArgs.GoogleProject);

                var authServiceUrl = parsedArgs.Local
                        ? string.Format(LocalEndPointUrlFormat, "4042")
                        : string.Format(CloudEndPointUrlFormat, "playfab-auth", parsedArgs.GoogleProject);

                var playerId = RandomString(15);
                Console.WriteLine($"Using a randomly generated PlayFab player ID: {playerId}");
                Console.WriteLine($"authServiceUrl: {authServiceUrl}");

                //This is the type of code i would put into the game because it is responsible
                // for talking directly to steam for encrypted app ticket and then sending it
                // to my servers to authenticate and exchange got a player identity token
                // First, get a token from PlayFab.
                PlayFabSettings.staticSettings.TitleId = parsedArgs.PlayFabTitleId;
                var playFabLoginTask = PlayFabClientAPI.LoginWithCustomIDAsync(new LoginWithCustomIDRequest
                {
                    TitleId       = parsedArgs.PlayFabTitleId,
                    CustomId      = playerId,
                    CreateAccount = true
                });
                var playFabLoginResult = playFabLoginTask.GetAwaiter().GetResult();
                if (playFabLoginResult.Error != null)
                {
                    Console.WriteLine($"Got login error from PlayFab: {playFabLoginResult.Error.ErrorMessage}");
                    Environment.Exit(1);
                    return;
                }

                var playFabId = playFabLoginResult.Result.PlayFabId;
                Console.WriteLine($"Got a token for PlayFab ID {playFabId}.");

                // Next, exchange the token with our auth service for a PIT.
                var playFabAuthClient = new AuthService.AuthServiceClient(
                    new Channel(authServiceUrl, ChannelCredentials.Insecure));
                var authResult = playFabAuthClient.ExchangePlayFabToken(new ExchangePlayFabTokenRequest
                {
                    PlayfabToken = playFabLoginResult.Result.SessionTicket
                });
                Console.WriteLine("Got a PIT.");
                var pitMetadata = new Metadata {
                    { PitRequestHeaderName, authResult.PlayerIdentityToken }
                };
                Console.WriteLine($"authResult.PlayerIdentityToken: {authResult.PlayerIdentityToken}");

                // Create a single-player party for the player.
                var partyClient = new PartyService.PartyServiceClient(
                    new Channel(partyServiceUrl, ChannelCredentials.Insecure));
                var partyResponse =
                    partyClient.CreateParty(new CreatePartyRequest {
                    MinMembers = 1, MaxMembers = 1
                }, pitMetadata);
                Console.WriteLine($"Created a new party with id {partyResponse.PartyId}.");

                var gatewayEndpoint = gatewayServiceUrl;
                var gatewayClient   =
                    new GatewayService.GatewayServiceClient(new Channel(gatewayEndpoint,
                                                                        ChannelCredentials.Insecure));

                gatewayClient.Join(new JoinRequest
                {
                    MatchmakingType = "match"
                }, pitMetadata);
                Console.WriteLine("Joined queue; waiting for match.");

                GetJoinStatusResponse resp = null;
                while (resp == null || !resp.Complete)
                {
                    Thread.Sleep(1000);
                    resp = gatewayClient.GetJoinStatus(new GetJoinStatusRequest {
                        PlayerId = playFabId
                    }, pitMetadata);
                }

                Console.WriteLine(
                    $"Got deployment: {resp.DeploymentName}. Login token: [{resp.LoginToken}].");
            });
        }
Example #4
0
        public UserJobsViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                AuthClient  = Helpers.Services.Instance.GetAuthServiceClient();
                Jobs        = new ObservableCollection <TblAuthJob>();
                BarcodeList = new ObservableCollection <BarCodeSettingsList>();
                DetailList  = new ObservableCollection <EmployeesView>();

                AuthClient.GetBarcodeDisplaySettingsHeaderCompleted += (s, sv) =>
                {
                    foreach (var item in sv.Result)
                    {
                        BarcodeList.Add(MapToBarcode(item));
                    }
                };
                AuthClient.GetBarcodeDisplaySettingsHeaderAsync();
                Client.GetGenericAsync("TblCompany", "%%", "%%", "%%", "Iserial", "ASC");
                Client.GetGenericCompleted += (s, sv) =>
                {
                    CompanyList = sv.Result;
                };
                AuthClient.SaveUserCompleted += (s, sv) =>
                {
                    var savedRow = MainRowList.ElementAt(sv.outindex);
                    if (savedRow != null)
                    {
                        savedRow.Iserial = sv.Result.Iserial;
                        MessageBox.Show("Saved Successfully");
                    }
                    else if (sv.Result.Ename == "ERROR_OCCURED")
                    {
                        MessageBox.Show("Error Occured, User NOT saved");
                    }
                };
                _axUsers = new ObservableCollection <AuthService.User>();
                Language = new List <Language>
                {
                    new Language {
                        CurrLan = 0, Lang = "Arabic"
                    },
                    new Language {
                        CurrLan = 1, Lang = "English"
                    }
                };

                AuthClient.GetEmpTableCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        DetailList.Add(row);
                    }
                    DetailFullCount = sv.fullCount;
                    Loading         = false;
                };

                MainRowList = new ObservableCollection <TblUserViewModel>();
                AuthClient.GetAllJobsAsync();
                AuthClient.GetAllJobsCompleted += (s, j) =>
                {
                    foreach (var item in j.Result)
                    {
                        Jobs.Add(item);
                    }
                };

                AuthClient.GetAxUserAsync();
                AuthClient.GetAxUserCompleted += (s, j) =>
                {
                    foreach (var item in j.Result)
                    {
                        AxUsers.Add(item);
                    }
                };

                AuthClient.GetAllUsersCompleted += (s, ds) =>
                {
                    foreach (var item in ds.Result)
                    {
                        var newRow = new TblUserViewModel();
                        newRow.InjectFrom(item);
                        newRow.CompanyPerRow          = new CRUDManagerService.GenericTable();
                        newRow.SecondaryCompanyPerRow = new CRUDManagerService.GenericTable();
                        newRow.PositionPerRow         = new CRUDManagerService.GenericTable();
                        newRow.BarcodePerRow          = new BarCodeSettingsList();
                        if (item.TblCompany1 != null)
                        {
                            newRow.CompanyPerRow.InjectFrom(item.TblCompany1);
                        }
                        if (item.TblCompany2 != null)
                        {
                            newRow.SecondaryCompanyPerRow.InjectFrom(item.TblCompany2);
                        }
                        if (item.TblPosition1 != null)
                        {
                            newRow.PositionPerRow.InjectFrom(item.TblPosition1);
                        }
                        newRow.BarcodePerRow = BarcodeList.FirstOrDefault(x => x.Iserial == newRow.PrintingCode);
                        MainRowList.Add(newRow);
                        newRow.JobPerRow = item.TblAuthJob;
                    }
                    Loading = false;
                };
                GetMaindata();

                AuthClient.GetLookUpAuthWarehouseTypesCompleted += (s, e) =>
                {
                    PermissionTypes = e.Result;
                };
                AuthClient.GetLookUpAuthWarehouseTypesAsync();
                AuthClient.GetAuthWarehousesCompleted += (s, e) =>
                {
                    WarehouseAuths = e.Result;
                };
                AuthClient.GetAuthJournalSettingCompleted += (s, e) =>
                {
                    JournalAuth = e.Result;
                };
                SavePermissions = new RelayCommand(() =>
                {
                    if (SelectedPermissionType != null && SelectedMainRow != null)
                    {
                        AuthClient.SaveAuthWarehousesAsync(SelectedMainRow.Iserial,
                                                           SelectedPermissionType.Iserial, WarehouseAuths);
                    }
                });


                SaveJournalAuth = new RelayCommand(() =>
                {
                    if (SelectedMainRow != null)
                    {
                        string comp = "";
                        if (SelectedMainRow.SecondaryCompanyPerRow != null)
                        {
                            comp = SelectedMainRow.SecondaryCompanyPerRow.Code;
                        }
                        if (comp == "")
                        {
                            if (SelectedMainRow.CompanyPerRow != null)
                            {
                                comp = SelectedMainRow.CompanyPerRow.Code;
                            }
                        }
                        AuthClient.SaveAuthJournalSettingAsync(SelectedMainRow.Iserial, comp, JournalAuth);
                    }
                });
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <SampleClientArguments>(args)
            .WithParsed(parsedArgs =>
            {
                var gatewayServiceUrl = parsedArgs.Local
                        ? string.Format(LocalEndPointUrlFormat, "4040")
                        : string.Format(CloudEndPointUrlFormat, "gateway", parsedArgs.GoogleProject);

                var partyServiceUrl = parsedArgs.Local
                        ? string.Format(LocalEndPointUrlFormat, "4041")
                        : string.Format(CloudEndPointUrlFormat, "party", parsedArgs.GoogleProject);

                var authServiceUrl = parsedArgs.Local
                        ? string.Format(LocalEndPointUrlFormat, "4042")
                        : string.Format(CloudEndPointUrlFormat, "playfab-auth", parsedArgs.GoogleProject);

                var playerId = RandomString(15);
                Console.WriteLine($"Using a randomly generated PlayFab player ID: {playerId}");

                // First, get a token from PlayFab.
                PlayFabSettings.staticSettings.TitleId = parsedArgs.PlayFabTitleId;
                var playFabLoginTask = PlayFabClientAPI.LoginWithCustomIDAsync(new LoginWithCustomIDRequest
                {
                    TitleId       = parsedArgs.PlayFabTitleId,
                    CustomId      = playerId,
                    CreateAccount = true
                });
                var playFabLoginResult = playFabLoginTask.GetAwaiter().GetResult();
                if (playFabLoginResult.Error != null)
                {
                    Console.WriteLine($"Got login error from PlayFab: {playFabLoginResult.Error.ErrorMessage}");
                    Environment.Exit(1);
                    return;
                }

                var playFabId = playFabLoginResult.Result.PlayFabId;

                Console.WriteLine($"Got a token for PlayFab ID {playFabId}.");

                // Next, exchange the token with our auth service for a PIT.
                var playFabAuthClient = new AuthService.AuthServiceClient(
                    new Channel(authServiceUrl, ChannelCredentials.Insecure));
                var authResult = playFabAuthClient.ExchangePlayFabToken(new ExchangePlayFabTokenRequest
                {
                    PlayfabToken = playFabLoginResult.Result.SessionTicket
                });
                Console.WriteLine("Got a PIT.");
                var pitMetadata = new Metadata {
                    { PitRequestHeaderName, authResult.PlayerIdentityToken }
                };

                // Create a single-player party for the player.
                var partyClient = new PartyService.PartyServiceClient(
                    new Channel(partyServiceUrl, ChannelCredentials.Insecure));
                var partyResponse =
                    partyClient.CreateParty(new CreatePartyRequest {
                    MinMembers = 1, MaxMembers = 1
                }, pitMetadata);
                Console.WriteLine($"Created a new party with id {partyResponse.PartyId}.");

                var gatewayEndpoint = gatewayServiceUrl;
                var gatewayClient   =
                    new GatewayService.GatewayServiceClient(new Channel(gatewayEndpoint,
                                                                        ChannelCredentials.Insecure));
                var operationsClient =
                    new Operations.OperationsClient(new Channel(gatewayEndpoint, ChannelCredentials.Insecure));

                var op = gatewayClient.Join(new JoinRequest
                {
                    MatchmakingType = "match"
                }, pitMetadata);
                Console.WriteLine("Joined queue; waiting for match.");

                while (!op.Done)
                {
                    Thread.Sleep(1000);
                    op = operationsClient.GetOperation(new GetOperationRequest
                    {
                        Name = op.Name
                    }, pitMetadata);
                }

                var response = op.Response.Unpack <JoinResponse>();
                Console.WriteLine(
                    $"Got deployment: {response.DeploymentName}. Login token: [{response.LoginToken}].");
            });
        }