ConfigReadFromConsole() static public method

static public ConfigReadFromConsole ( ) : config
return config
Exemplo n.º 1
0
        static void SampleRun()
        {
            Console.WriteLine("this Programm reads the memory of the eve online client process.");
            Console.WriteLine("start an eve online client and login to your account. Then press any key to continue.\n");
            Console.ReadKey();

            var Config = Extension.ConfigReadFromConsole();

            if (null == Config)
            {
                Console.WriteLine("reading config failed.");
                return;
            }

            var LicenseClient = new BotEngine.Interface.LicenseClient()
            {
                ServerAddress = Config.LicenseServerAddress, LicenseKey = Config.LicenseKey
            };

            Console.WriteLine();
            Console.WriteLine("connecting to " + (LicenseClient?.ServerAddress ?? "") + " using Key \"" + (LicenseClient?.LicenseKey ?? "") + "\" ....");

            while (!LicenseClient.AuthCompleted)
            {
                LicenseClient.ExchangeAuth();

                Thread.Sleep(1111);
            }

            var AuthResult = LicenseClient?.ExchangeAuthLast?.Value?.Response;

            var LicenseServerSessionId = AuthResult?.SessionId;

            Console.WriteLine("Auth completed, SessionId = " + (LicenseServerSessionId ?? "null"));

            Console.WriteLine("\nstarting to set up the sensor and read from memory.\nthe initial measurement takes longer.");

            var SensorAppManager = new BotEngine.Interface.InterfaceAppManager();

            var SensorServerHub = new SimpleSensorServerDispatcher()
            {
                SensorAppManager = SensorAppManager, LicenseClient = LicenseClient
            };

            BotEngine.Interface.FromProcessMeasurement <IMemoryMeasurement> MeasurementMemoryReceivedLast = null;

            while (true)
            {
                try
                {
                    //	Limit the frequency of measurements.
                    var RequestedMeasurementTime =
                        (MeasurementMemoryReceivedLast?.Begin + MeasurementTimeDistanceMin) ??
                        Bib3.Glob.StopwatchZaitMiliSictInt();

                    //	not specifying a subset to read, the sensor will simply read all available (types in MemoryStruct namespace) structures from memory.
                    SensorServerHub.Exchange(
                        Config.EveOnlineClientProcessId,
                        RequestedMeasurementTime,
                        Measurement =>
                    {
                        MeasurementMemoryReceivedLast = Measurement;
                        MeasurementReceived(Measurement);
                    });
                }
                finally
                {
                    Thread.Sleep(250);
                }
            }
        }
Exemplo n.º 2
0
        static void SampleRun()
        {
            Console.WriteLine("this program reads the memory of the eve online client process.");
            Console.WriteLine("start an eve online client and login to your account. Then press any key to continue.\n");
            Console.ReadKey();

            var Config = Extension.ConfigReadFromConsole();

            if (null == Config)
            {
                Console.WriteLine("reading config failed.");
                return;
            }

            var licenseClientConfig = new LicenseClientConfig
            {
                ApiVersionAddress = Config.LicenseServerAddress,
                Request           = new AuthRequest
                {
                    ServiceId  = Config.ServiceId,
                    LicenseKey = Config.LicenseKey,
                    Consume    = true,
                },
            };

            Console.WriteLine();
            Console.WriteLine("connecting to " + (licenseClientConfig?.ApiOverviewAddress ?? "") + " using Key \"" + (licenseClientConfig?.Request?.LicenseKey ?? "") + "\" ....");

            var sensorServerDispatcher = new SimpleInterfaceServerDispatcher
            {
                LicenseClientConfig = licenseClientConfig,
            };

            sensorServerDispatcher.CyclicExchangeStart();

            var exchangeAuth = sensorServerDispatcher?.LicenseClient?.ExchangeAuthLast?.Value;

            Console.WriteLine("Auth exchange completed ");

            if (exchangeAuth.AuthSuccess() ?? false)
            {
                Console.WriteLine("successful");
            }
            else
            {
                Console.WriteLine("with error: " + Environment.NewLine + exchangeAuth?.SerializeToString(Newtonsoft.Json.Formatting.Indented));
                return;
            }

            Console.WriteLine("\nstarting to set up the sensor and read from memory.\nthe initial measurement takes longer.");

            for (;;)
            {
                var response = sensorServerDispatcher?.InterfaceAppManager?.MeasurementTakeNewRequest(Config.EveOnlineClientProcessId);

                if (null == response)
                {
                    Console.WriteLine("Sensor Interface not yet ready.");
                }
                else
                {
                    MeasurementReceived(response?.MemoryMeasurement);
                }

                Thread.Sleep(MeasurementTimeDistance);
            }
        }