private static Connection ConnectClientLocator(string[] arguments)
        {
            var hostname = arguments[1];
            var pit      = arguments[2];
            var lt       = arguments[3];

            var playerIdentityCredentials = new PlayerIdentityCredentials();

            playerIdentityCredentials.PlayerIdentityToken = pit;
            playerIdentityCredentials.LoginToken          = lt;

            var locatorParameters = new LocatorParameters();

            locatorParameters.CredentialsType = LocatorCredentialsType.PlayerIdentity;
            locatorParameters.PlayerIdentity  = playerIdentityCredentials;

            var locator = new Locator(hostname, locatorParameters);

            var connectionParameters = new ConnectionParameters();

            connectionParameters.WorkerType             = WorkerType;
            connectionParameters.Network.ConnectionType = NetworkConnectionType.Tcp;
            connectionParameters.Network.UseExternalIp  = true;

            using (var future = locator.ConnectAsync(connectionParameters))
            {
                return(future.Get());
            }
        }
示例#2
0
        public async Task<Connection> CreateAsync(ConnectionParameters parameters, CancellationToken? token = null)
        {
            parameters.Network.UseExternalIp = true;

            if (UseDevAuthFlow)
            {
                PlayerIdentityToken = GetDevelopmentPlayerIdentityToken();
                var loginTokenDetails = GetDevelopmentLoginTokens(parameters.WorkerType, PlayerIdentityToken);
                LoginToken = SelectLoginToken(loginTokenDetails);
            }

            var locatorParameters = new LocatorParameters
            {
                PlayerIdentity = new PlayerIdentityCredentials
                {
                    PlayerIdentityToken = PlayerIdentityToken,
                    LoginToken = LoginToken
                },
                CredentialsType = LocatorCredentialsType.PlayerIdentity,
                UseInsecureConnection = UseInsecureConnection
            };

            using (var locator = new Locator(LocatorHost, LocatorPort, locatorParameters))
            {
                using (var connectionFuture = locator.ConnectAsync(parameters))
                {
                    return await Utils.TryToConnectAsync(connectionFuture, token).ConfigureAwait(false);
                }
            }
        }
示例#3
0
        private static Connection ConnectClientWithLocator(string hostname, string projectName, string deploymentId,
                                                           string loginToken, ConnectionParameters connectionParameters)
        {
            Connection connection;

            connectionParameters.Network.UseExternalIp = true;

            var locatorParameters = new LocatorParameters
            {
                ProjectName     = projectName,
                CredentialsType = LocatorCredentialsType.LoginToken,
                LoginToken      = { Token = loginToken }
            };

            var locator = new Locator(hostname, locatorParameters);

            using (var future = locator.ConnectAsync(deploymentId, connectionParameters, QueueCallback))
            {
                connection = future.Get();
            }

            connection.SendLogMessage(LogLevel.Info, LoggerName, "Successfully connected using the Locator");

            return(connection);
        }
        private static LocatorParameters CreateLocatorParameters(WorkerConfiguration instance)
        {
            var credentials = string.IsNullOrEmpty(instance.SteamToken) ? LocatorCredentialsType.LoginToken : LocatorCredentialsType.Steam;

            var locatorParameters = new LocatorParameters
            {
                ProjectName     = instance.ProjectName,
                CredentialsType = credentials
            };

            switch (locatorParameters.CredentialsType)
            {
            case LocatorCredentialsType.LoginToken:
                locatorParameters.LoginToken.Token = instance.LoginToken;
                break;

            case LocatorCredentialsType.Steam:
                locatorParameters.Steam.DeploymentTag = instance.DeploymentTag;
                locatorParameters.Steam.Ticket        = instance.SteamToken;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(locatorParameters);
        }