Esempio n. 1
0
        static void Main(string[] args)
        {
            string path =
                @"D:\repos\BstServer\EchoCurrentDirectory\bin\Debug\EchoCurrentDirectory.exe";
            //path = "cmd";
            L4D2AppHost host = new L4D2AppHost(path, new HostSettings
            {
                ShowWindow            = false,
                Encoding              = Encoding.GetEncoding(936),
                RedirectStandardInput = false
            });

            host.DataReceived += Host_DataReceived;
            host.Run();
            //host.UserConfig.SteamUsers.Add(new BstServer.Models.SteamUser());
            //var d = user.GetDayInfo(18, 11, 17);
            //var m = user.GetMonthInfo(18, 12);
            //var y = user.GetYearInfo(18);
            //double ssb = host.UserConfig.GetUserRate(user,18,11,16);
            //var ssb = y.DamageList;
            //var sbb = d.DamageList;
            //var list = File.ReadAllLines(@"C:\Users\YureruMiira\Desktop\l4dinfos.txt");
            //foreach (var s in list)
            //{
            //    host._queue.Enqueue(s);
            //}
            Console.Read();
            return;

            //host.DataReceived += Host_DataReceived;
            //host.Run();
            var task = new Task(() =>
            {
                Thread.CurrentThread.IsBackground = false;
                host.WaitForExit();
                Console.WriteLine("Process has exit. Press any key to continue...");
                Console.ReadKey();
            });

            task.Start();

            if (host.CanSendMessage)
            {
                while (true)
                {
                    var sb = Console.ReadLine();
                    host.SendMessage(sb);
                }
            }
            else
            {
                host.WaitForExit();
            }
        }
Esempio n. 2
0
 public IActionResult SendCommand(string command)
 {
     try
     {
         _l4D2AppHost.SendMessage(command);
         return(Json(new JsonModelBase(200, "success", "success", null)));
     }
     catch (Exception e)
     {
         return(Json(new JsonModelBase(500, "failed", e.Message, null)));
     }
 }