Пример #1
0
 public PlayerController(IPlayerClient playerClient, IMotSlideShowRetriever motSlideShowRetriever, IMotSlideshowSender motSlideshowSender, ILoggerFactory loggerFactory)
 {
     this.playerClient          = playerClient;
     this.motSlideShowRetriever = motSlideShowRetriever;
     this.motSlideshowSender    = motSlideshowSender;
     this.logger = loggerFactory.CreateLogger("PlayerController");
 }
 private RoyaleApiStandalone(IVersionClient versionClient, IPlayerClient playerClient, IClanClient clanClient, ITournamentClient tournamentClient)
 {
     VersionClient    = versionClient;
     PlayerClient     = playerClient;
     ClanClient       = clanClient;
     TournamentClient = tournamentClient;
 }
Пример #3
0
 /**
  * Read the contents of this packet and perform logic
  * @return This packet
  * @throws IOException If there was a problem reading the packet
  */
 public Packet HandlePacket(IPlayerClient client)
 {
     this.client = client;
     Ended       = false;
     Handle();
     return(this);
 }
Пример #4
0
        public void Inject(IPlayerClient client, UnityProject project)
        {
            m_Client  = client;
            m_Project = project;

            m_Storage = new PlayerStorage(UnityEngine.Reflect.ProjectServer.ProjectDataPath, true, false);
        }
Пример #5
0
 public PlayerController(
     IRequestFieldExtractor extractor,
     IPlayerClient playerClient)
 {
     requestFieldExtractor = extractor;
     playerService         = new PlayerService(playerClient);
 }
 public static BattleriteClient Create(
     IAssetClient assetClient,
     IMatchClient matchClient,
     IPlayerClient playerClient)
 {
     return(new BattleriteClient(assetClient, matchClient, playerClient));
 }
Пример #7
0
 public BasePlayerStrategy(IUnitOfWorkManager unitOfWorkManager,
                           IPlayerClient playerClient,
                           IMapper <PlayerClientModel, PlayerModel> playerMapper)
 {
     _unitOfWorkManager = unitOfWorkManager;
     _playerClient      = playerClient;
     _playerMapper      = playerMapper;
 }
Пример #8
0
 private ClashRoyaleApiStandalone(IPlayerClient playerClient, IClanClient clanClient, ILocationClient locationClient, ITournamentClient tournamentClient, ICardClient cardClient)
 {
     PlayerClient     = playerClient;
     ClanClient       = clanClient;
     LocationClient   = locationClient;
     TournamentClient = tournamentClient;
     CardClient       = cardClient;
 }
Пример #9
0
 public PlayerSLAdaptor(string Name, string SessionID, string photoUrl, IPlayerClient webClient)
 {
     this.SessionID = SessionID;
     this._name = Name;
     this.webClient = webClient;
     this.PhotoUrl = photoUrl;
     ResponseRecieved();
 }
Пример #10
0
 public CaptainsByGameWeek(IOptions <FplbotOptions> options, IEntryClient entryClient, IPlayerClient playerClient, ILeagueClient leagueClient, IChipsPlayed chipsPlayed)
 {
     _options      = options;
     _entryClient  = entryClient;
     _playerClient = playerClient;
     _leagueClient = leagueClient;
     _chipsPlayed  = chipsPlayed;
 }
 internal BattleriteClient(
     IAssetClient assets,
     IMatchClient matches,
     IPlayerClient players)
 {
     Players = players;
     Matches = matches;
     Assets  = assets;
 }
Пример #12
0
 public PlayerService(
     IPlayerClient playerClient,
     ISessionManager sessionManager,
     IStrategyResolver strategyResolver)
 {
     _playerClient     = playerClient;
     _sessionManager   = sessionManager;
     _strategyResolver = strategyResolver;
 }
Пример #13
0
    /**
     * Start writing this packet with the given data
     * @param args The data for this packet
     * @return This packet
     * @throws IOException If there was a problem reading the packet
     */
    public Packet WritePacket(IPlayerClient client, params System.Object[] args)
    {
        this.client = client;

        preserve      = false;
        preservedData = null;
        Write(args);
        return(this);
    }
Пример #14
0
 public FplPlayerCommandHandler(
     ISlackClientService slackClient,
     IPlayerClient playerClient,
     ITeamsClient teamsClient)
 {
     _playerClient       = playerClient;
     _teamsClient        = teamsClient;
     _slackClientService = slackClient;
 }
        public ClientListener(IPlayerClient client)
        {
            m_ManifestUpdates = new ConcurrentQueue <ManifestUpdatedEventArgs>();
            m_StatusUpdates   = new ConcurrentQueue <ConnectionStatus>();

            this.client = client;
            this.client.ManifestUpdated         += OnManifestUpdated;
            this.client.ConnectionStatusChanged += OnConnectionStatusChanged;
        }
        public async Task StartContainersForScenarioRun(String scenarioName)
        {
            String testFolder = scenarioName;

            Logging.Enabled();

            Guid testGuid = Guid.NewGuid();

            this.TestId = testGuid;
            // Setup the container names
            this.ManagementAPIContainerName       = $"rest{testGuid:N}";
            this.EventStoreContainerName          = $"eventstore{testGuid:N}";
            this.SecurityServiceContainerName     = $"auth{testGuid:N}";
            this.SubscriberServiceId              = testGuid;
            this.SubscriptionServiceContainerName = $"subService{testGuid:N}";
            this.MessagingServiceContainerName    = $"messaging{testGuid:N}";

            this.EventStoreConnectionString =
                $"EventStoreSettings:ConnectionString=ConnectTo=tcp://admin:changeit@{this.EventStoreContainerName}:1113;VerboseLogging=true;";
            this.SecurityServiceAddress = $"AppSettings:SecurityService=http://{this.SecurityServiceContainerName}:5001";
            this.AuthorityAddress       = $"SecurityConfiguration:Authority=http://{this.SecurityServiceContainerName}:5001";
            this.SubscriptionServiceConnectionString =
                $"\"ConnectionStrings:SubscriptionServiceConfigurationContext={Setup.GetConnectionString("SubscriptionServiceConfiguration")}\"";
            this.ManagementAPIReadModelConnectionString = $"\"ConnectionStrings:ManagementAPIReadModel={Setup.GetConnectionString($"ManagementAPIReadModel{testGuid:N}")}\"";
            this.ManagementAPISeedingType = "SeedingType=IntegrationTest";
            this.MessagingServiceAddress  = $"ServiceAddresses:MessagingService=http://{this.MessagingServiceContainerName}:5002";

            this.SetupTestNetwork();
            this.SetupManagementAPIContainer(testFolder);
            this.SetupSecurityServiceContainer(testFolder);
            this.SetupEventStoreContainer(testFolder);
            this.SetupSubscriptionServiceContainer(testFolder);
            this.SetupMessagingService(testFolder);

            // Cache the ports
            this.ManagementApiPort    = this.ManagementAPIContainer.ToHostExposedEndpoint("5000/tcp").Port;
            this.EventStorePort       = this.EventStoreContainer.ToHostExposedEndpoint("2113/tcp").Port;
            this.SecurityServicePort  = this.SecurityServiceContainer.ToHostExposedEndpoint("5001/tcp").Port;
            this.MessagingServicePort = this.MessagingServiceContainer.ToHostExposedEndpoint("5002/tcp").Port;

            await this.SetupSubscriptionServiceConfig(CancellationToken.None).ConfigureAwait(false);

            await this.SetupSecurityServiceConfig(CancellationToken.None).ConfigureAwait(false);

            // Setup the base address resolver
            Func <String, String> baseAddressResolver = api => $"http://127.0.0.1:{this.ManagementApiPort}";

            HttpClient httpClient = new HttpClient();


            this.GolfClubAdministratorClient = new GolfClubAdministratorClient(baseAddressResolver, httpClient);
            this.GolfClubClient         = new Service.Client.v2.GolfClubClient(baseAddressResolver, httpClient);
            this.PlayerClient           = new Service.Client.v2.PlayerClient(baseAddressResolver, httpClient);
            this.ReportingClient        = new Service.Client.v2.ReportingClient(baseAddressResolver, httpClient);
            this.HttpClient             = new HttpClient();
            this.HttpClient.BaseAddress = new Uri(baseAddressResolver(String.Empty));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiClient" /> class.
 /// </summary>
 /// <param name="playerClient">The player client.</param>
 /// <param name="golfClubClient">The golf club client.</param>
 /// <param name="tournamentClient">The tournament client.</param>
 /// <param name="reportingClient">The reporting client.</param>
 public ApiClient(IPlayerClient playerClient,
                  IGolfClubClient golfClubClient,
                  ITournamentClient tournamentClient,
                  IReportingClient reportingClient)
 {
     this.PlayerClient     = playerClient;
     this.GolfClubClient   = golfClubClient;
     this.TournamentClient = tournamentClient;
     this.ReportingClient  = reportingClient;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TestDataGenerator"/> class.
 /// </summary>
 /// <param name="golfClubClient">The golf club client.</param>
 /// <param name="playerClient">The player client.</param>
 /// <param name="tournamentClient">The tournament client.</param>
 /// <param name="addressResolver">The address resolver.</param>
 public TestDataGenerator(IGolfClubClient golfClubClient,
                          IPlayerClient playerClient,
                          ITournamentClient tournamentClient,
                          Func <String, String> addressResolver)
 {
     this.GolfClubClient   = golfClubClient;
     this.PlayerClient     = playerClient;
     this.TournamentClient = tournamentClient;
     this.HttpClient       = new HttpClient();
     this.AddressResolver  = addressResolver;
     this.AccessTokens     = new Dictionary <String, TokenResponse>();
 }
        public void Dispose()
        {
            if (client == null)
            {
                return;
            }

            client.ManifestUpdated         -= OnManifestUpdated;
            client.ConnectionStatusChanged -= OnConnectionStatusChanged;
            client.Dispose();
            client = null;
        }
Пример #20
0
 public TransfersByGameWeek(
     IOptions <FplbotOptions> fplbotOptions,
     ILeagueClient leagueClient,
     IPlayerClient playerClient,
     ITransfersClient transfersClient,
     IEntryClient entryClient
     )
 {
     _fplbotOptions   = fplbotOptions.Value;
     _leagueClient    = leagueClient;
     _playerClient    = playerClient;
     _transfersClient = transfersClient;
     _entryClient     = entryClient;
 }
Пример #21
0
 public GoalMonitorRecurringAction(
     IOptions <FplbotOptions> options,
     IGameweekClient gwClient,
     ILogger <NextGameweekRecurringAction> logger,
     ITokenStore tokenStore,
     ISlackClientBuilder slackClientBuilder,
     IPlayerClient playerClient,
     IGoalsDuringGameweek goalsDuringGameweek,
     ITransfersByGameWeek transfersByGameWeek) :
     base(options, gwClient, logger, tokenStore, slackClientBuilder)
 {
     _playerClient        = playerClient;
     _goalsDuringGameweek = goalsDuringGameweek;
     _transfersByGameWeek = transfersByGameWeek;
 }
Пример #22
0
        private IPlayerClient CreateOrGetPlayerClient(
            JsonSerializerSettings jsonSerializerSettings,
            IRequestUrlBuilder requestUrlBuilder,
            IRequester requester,
            IAssetClient assetClient)
        {
            IPlayerClient playerClient = null;

            playerClientFactory.Or(() => new PlayerClientFactory())
            .MatchSome(
                factory => playerClient = factory.Create(
                    assetClient,
                    requestUrlBuilder,
                    requester,
                    jsonSerializerSettings));

            return(playerClient);
        }
Пример #23
0
        internal static async Task DownloadAndStore(IPlayerClient client, string sourceId, ManifestEntry entry, SyncManifest newManifest,
                                                    string downloadFolder, DownloadProgress progress)
        {
            Exception exception = null;

            try
            {
                var syncModel = await client.GetSyncModelAsync(sourceId, entry.ModelPath, entry.Hash);

                if (syncModel != null)
                {
                    // Replace model name with local model paths
                    syncModel.Name = entry.ModelPath;
                    SetReferencedSyncModelPath(syncModel, newManifest);

                    var fullPath  = Path.Combine(downloadFolder, entry.ModelPath);
                    var directory = Path.GetDirectoryName(fullPath);

                    await RunFileIOOperation(async() =>
                    {
                        Directory.CreateDirectory(directory);
                        await PlayerFile.SaveAsync(syncModel, fullPath);
                    });
                }
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                progress.errors.Enqueue(new DownloadError(exception, entry));
            }

            progress.ReportCompleted();
        }
Пример #24
0
    public void EndTCPFlush()
    {
        if (client == null)
        {
            return;
        }

        byte[] data = EndBytes();
        try {
            client.write(data);
            client.flush();
        } catch (IOException e) {
            if (e.Message.Contains("Connection reset"))
            {
                client.disconnect();
            }
            else if (Ghost.IsDebug)
            {
                Debug.Log(e);
            }
        }

        client = null;
    }
Пример #25
0
 private void InstallPlayerClient()
 {
     client = new PlayerClient(this, dataProvider);
     playerController.Client = client;
 }
Пример #26
0
 public ViewerSLAdaptor(string SessionID, IPlayerClient webClient)
 {
     this.SessionID = SessionID;
     this.webClient = webClient;
 }
Пример #27
0
 public void ReuseFor(IPlayerClient client)
 {
     this.client = client;
     Ended       = false;
     Position    = 0;
 }
Пример #28
0
 public PlayerService(IPlayerClient playerClient)
 {
     this.playerClient = playerClient;
 }
    async Task DownloadProject(IPlayerClient client, Project project, string folder)
    {
        lock (m_ProgressLock)
        {
            m_Progress = 0.0f;
        }

        var storage = new PlayerStorage(folder, false, true);

        try
        {
            var manifestEntries = (await client.GetManifestsAsync()).ToArray();

            onProgressChanged?.Invoke(0.0f);

            var total          = manifestEntries.Length;
            var projectPercent = 1.0f / total;

            var localManifests = new Dictionary <string, SyncManifest>();

            IEnumerable <SourceProject> localSourceProjects = null;

            try
            {
                localSourceProjects = storage.LoadProjectManifests(project).ToArray();
            }
            catch (ReflectVersionException)
            {
                if (manifestEntries.Length == 0)
                {
                    throw new Exception($"Cannot open project {project.name} because it has been exported with a different version of Unity Reflect.");
                }
            }

            if (localSourceProjects != null)
            {
                foreach (var sourceProject in localSourceProjects)
                {
                    localManifests.Add(sourceProject.sourceId, sourceProject.manifest);
                }
            }

            storage.SaveProjectData(project);

            for (int i = 0; i < total; ++i)
            {
                var manifestEntry = manifestEntries[i];

                localManifests.TryGetValue(manifestEntry.SourceId, out var oldManifest);

                await DownloadManifestDiff(client, oldManifest, manifestEntry.Manifest, project, manifestEntry.SourceId, storage);
            }
        }
        finally
        {
            client?.Dispose();
        }

        lock (m_ProgressLock)
        {
            m_Progress = 1.0f;
        }
    }
    public IEnumerator Download(Project project)
    {
        IPlayerClient client = null;

        if (!Directory.Exists(m_Folder))
        {
            Directory.CreateDirectory(m_Folder);
        }
        try
        {
            client = Player.CreateClient(project, ProjectServer.UnityUser, ProjectServer.Client);
        }
        catch (ConnectionException ex)
        {
            var    unityProject = (UnityProject)project;
            string message;
            if (unityProject.Host.IsLocalService)
            {
                message = "A connection with your local server could not be established. Make sure the Unity Reflect Service is running.";
            }
            else
            {
                if (unityProject.Host.ServerName == "Cloud")
                {
                    message = $"A connection with Reflect Cloud could not be established.";
                }
                else
                {
                    message = $"A connection with the server {unityProject.Host.ServerName} could not be established. This server may be outside your local network (LAN) or may not accept external connections due to firewall policies.";
                }
            }

            throw new ConnectionException(message, ex);
        }

        var task = Task.Run(() => DownloadProject(client, project, m_Folder));

        var lastProgress = 0.0f;

        onProgressChanged?.Invoke(0.0f);

        do
        {
            lock (m_ProgressLock)
            {
                if (lastProgress != m_Progress)
                {
                    lastProgress = m_Progress;
                    onProgressChanged?.Invoke(m_Progress);
                }
            }

            yield return(null);
        } while (!task.IsCompleted);

        if (task.IsFaulted)
        {
            onError?.Invoke(task.Exception);
        }

        onProgressChanged?.Invoke(1.0f);
    }
    async Task DownloadManifestDiff(IPlayerClient client, SyncManifest oldManifest, SyncManifest newManifest,
                                    UnityProject project, string sourceId, PlayerStorage storage)
    {
        List <ManifestEntry> entries;

        if (oldManifest == null)
        {
            var content = newManifest.Content;
            entries = content.Values.ToList();
        }
        else
        {
            ParseManifest(oldManifest.Content, newManifest.Content, out var modified, out var deleted);
            entries = modified.ToList();

            // TODO Handle deleted models
        }

        var destinationFolder = storage.GetSourceProjectFolder(project, sourceId);
        var downloadFolder    = Path.Combine(destinationFolder, k_TemporaryFolder);

        var progress = new ProjectManagerInternal.DownloadProgress();

        progress.SetTotal(entries.Count);

        var tasks = entries.Select(entry => ProjectManagerInternal.DownloadAndStore(client, sourceId, entry, newManifest, downloadFolder, progress)).ToList();

        // Don't forget the manifest itself
        tasks.Add(ProjectManagerInternal.RunFileIOOperation(() =>
        {
            newManifest.EditorSave(downloadFolder);
            return(Task.CompletedTask);
        }));


        // Wait for all download to finish
        var task = Task.WhenAll(tasks);

        while (!task.IsCompleted)
        {
            lock (m_ProgressLock)
            {
                m_Progress = progress.percent;
            }

            await Task.Delay(200);
        }

        // TODO Handle errors in the DownloadProgress

        // Backward compatibility with local viewer cache that have SyncPrefab as a file.
        var prefabPath = SyncInstance.GetPrefabPath(downloadFolder);

        if (prefabPath == null)
        {
            var prefabName = sourceId + SyncPrefab.Extension;
            var syncPrefab = SyncInstance.GenerateSyncPrefabFromManifest(prefabName, downloadFolder, newManifest);
            var fullPath   = Path.Combine(downloadFolder, prefabName);

            PlayerFile.Save(syncPrefab, fullPath);
        }

        // Delete SyncInstances since they cannot be imported
        var instancesFolder = Path.Combine(downloadFolder, "instances");

        if (Directory.Exists(instancesFolder))
        {
            Directory.Delete(instancesFolder, true);
        }

        // Move all content from temporary download folder to the final destination
        MoveDirectory(downloadFolder, destinationFolder);
    }
Пример #32
0
 public GameClient(IPlayerClient playerClient, ISinglePlayerGameFactory gameFactory)
 {
     this.playerClient = playerClient;
     this.gameFactory  = gameFactory;
 }