Beispiel #1
0
        /// <summary>
        /// Examines every active client and sorts each by the base path of the its player.
        /// </summary>
        /// <param name="processName">The name of the executable of the client (excluding the
        /// ".exe" extension).</param>
        public ActiveClients(string processName)
        {
            _processName = processName;

            Mages    = new List <MageClient>();
            Poets    = new List <PoetClient>();
            Rogues   = new List <RogueClient>();
            Warriors = new List <WarriorClient>();
            Peasants = new List <PeasantClient>();

            var processes = Process.GetProcesses();

            Log.Information("All processes ({Length})", processes.Length);
            foreach (var process in processes)
            {
                Log.Information("Name: ({Length})", process.ProcessName);
            }

            Log.Information("Retrieving process list by name, \"{processName}\"...", processName);
            var clients = Process.GetProcessesByName(processName);

            Log.Information("Got {Length} clients", clients.Length);

            foreach (var client in clients)
            {
                var tkClientFactory = new TkClientFactory(client.Id);
                var path            = tkClientFactory.GetBasePath();
                Log.Information("Found client path, \"{path}\"", path);
                switch (path)
                {
                case TkClient.BasePath.Mage:
                    Mages.Add(tkClientFactory.BuildMage());
                    break;

                case TkClient.BasePath.Poet:
                    Poets.Add(tkClientFactory.BuildPoet());
                    break;

                case TkClient.BasePath.Rogue:
                    Rogues.Add(tkClientFactory.BuildRogue());
                    break;

                case TkClient.BasePath.Warrior:
                    Warriors.Add(tkClientFactory.BuildWarrior());
                    break;

                case TkClient.BasePath.Peasant:
                    Peasants.Add(tkClientFactory.BuildPeasant());
                    break;

                default:
                    throw new Exception($"Invalid path '{tkClientFactory.TkSelf.Path}' could not be classified into a base path.");
                }
            }

            Clients = GetClients();
        }
Beispiel #2
0
        /// <summary>
        /// Examines every active client and sorts each by the base path of the its player.
        /// </summary>
        /// <param name="processName">The name of the executable of the client (with or
        /// without the ".exe" extension).</param>
        public ActiveClients(string processName)
        {
            _processName = Path.GetFileNameWithoutExtension(processName);

            Mages    = new List <MageClient>();
            Poets    = new List <PoetClient>();
            Rogues   = new List <RogueClient>();
            Warriors = new List <WarriorClient>();

            var clients = Process.GetProcessesByName(_processName);

            foreach (var client in clients)
            {
                var tkClientFactory = new TkClientFactory(client.Id);
                var path            = tkClientFactory.GetBasePath();
                switch (path)
                {
                case TkClient.BasePath.Mage:
                    Mages.Add(tkClientFactory.BuildMage());
                    break;

                case TkClient.BasePath.Poet:
                    Poets.Add(tkClientFactory.BuildPoet());
                    break;

                case TkClient.BasePath.Rogue:
                    Rogues.Add(tkClientFactory.BuildRogue());
                    break;

                case TkClient.BasePath.Warrior:
                    Warriors.Add(tkClientFactory.BuildWarrior());
                    break;

                case TkClient.BasePath.None:
                    break;

                default:
                    throw new Exception($"Invalid path '{tkClientFactory.TkSelf.Path}' could not be classified into a base path.");
                }
            }

            Clients = GetClients();
        }