示例#1
0
        /// <summary>Instructs the client to connect to the server.</summary>
        /// <param name="display">Where to capture display output (such as console and text logs).</param>
        /// <returns>True if successfully connected.</returns>
        public bool Connect(MultiUpdater display)
        {
            try
            {
                _client = new TcpClient();

                // Use default mud port. TODO: Read and use configured port?
                _client.Connect(new IPEndPoint(IPAddress.Loopback, 4000));

                int attempts = 0;
                while (!_client.Connected && attempts++ < 10)
                {
                    display.Notify("> Connecting to mud server on localhost port 4000...");
                    Thread.Sleep(1000);
                }

                _display = display;
                _netstr = _client.GetStream();

                return true;
            }
            catch (Exception ex)
            {
                _display.Notify("> Fatal Error: " + ex);
                _client = null;
                return false;
            }
        }
示例#2
0
        /// <summary>Instructs the client to connect to the server.</summary>
        /// <param name="display">Where to capture display output (such as console and text logs).</param>
        /// <returns>True if successfully connected.</returns>
        public bool Connect(MultiUpdater display)
        {
            try
            {
                client = new TcpClient();

                // Use default mud port. TODO: Read and use configured port?
                client.Connect(new IPEndPoint(IPAddress.Loopback, 4000));

                int attempts = 0;
                while (!client.Connected && attempts++ < 10)
                {
                    display.Notify("> Connecting to mud server on localhost port 4000...");
                    Thread.Sleep(1000);
                }

                this.display = display;
                netStream    = client.GetStream();

                return(true);
            }
            catch (Exception ex)
            {
                this.display.Notify("> Fatal Error: " + ex);
                client = null;
                return(false);
            }
        }
示例#3
0
        /// <summary>Main entry point into the test harness.</summary>
        public static void Main()
        {
            string logFileName = "Log_" + DateTime.Now.ToShortDateString() + ".txt";

            logFileName = logFileName.Replace('\\', '_').Replace('/', '_');
            var consoleDisplay = new ConsoleUpdater();
            var textLogWriter  = new TextLogUpdater(logFileName);
            var display        = new MultiUpdater(consoleDisplay, textLogWriter);

            var app = Application.Instance;

            app.SubscribeToSystem(display);

            app.Start();

            // TODO: Consider reflecting implementers of ITestHarnessCommand to keep this automatically up to date?
            ITestHarnessCommand[] commandObjects = { new HelpCommand(), new UpdateActionsCommand(), new RunTestsCommand() };
            IDictionary <string, ITestHarnessCommand> commands = new ConcurrentDictionary <string, ITestHarnessCommand>();

            foreach (var cmdObj in commandObjects)
            {
                foreach (var name in cmdObj.Names)
                {
                    commands[name] = cmdObj;
                }
            }

            var input = string.Empty;

            while (true)
            {
                input = Console.ReadLine();
                if (input != null)
                {
                    // TODO: Console.ReadLine probably never includes newlines; this code is probably not doing what was intended!
                    string[] words = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    if (words.Length == 0)
                    {
                        continue;
                    }
                    else if ("shutdown".Equals(input, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }

                    var cmd = words[0];
                    if (commands.ContainsKey(cmd))
                    {
                        commands[cmd].Execute(app, display, words);
                    }
                    else
                    {
                        display.Notify(string.Format("> Command Not Recognized. [{0}]", string.Join(" ", words)));
                    }
                }

                // This is for Mono compatability.
                input = string.Empty;
            }

            app.Stop();

            display.Notify("Press enter to quit...");
            Console.ReadLine();
        }
示例#4
0
        /// <summary>Main entry point into the test harness.</summary>
        public static void Main()
        {
            string logFileName = "Log_" + DateTime.Now.ToShortDateString() + ".txt";
            logFileName = logFileName.Replace('\\', '_').Replace('/', '_');
            var consoleDisplay = new ConsoleUpdater();
            var textLogWriter = new TextLogUpdater(logFileName);
            var display = new MultiUpdater(consoleDisplay, textLogWriter);

            var app = Application.Instance;

            app.SubscribeToSystem(display);

            app.Start();

            // TODO: Consider reflecting implementers of ITestHarnessCommand to keep this automatically up to date?
            ITestHarnessCommand[] commandObjects = { new HelpCommand(), new UpdateActionsCommand(), new RunTestsCommand() };
            IDictionary<string, ITestHarnessCommand> commands = new ConcurrentDictionary<string, ITestHarnessCommand>();

            foreach (var cmdObj in commandObjects)
            {
                foreach (var name in cmdObj.Names)
                {
                    commands[name] = cmdObj;
                }
            }

            var input = string.Empty;

            while (true)
            {
                input = Console.ReadLine();
                if (input != null)
                {
                    // TODO: Console.ReadLine probably never includes newlines; this code is probably not doing what was intended!
                    string[] words = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    if (words.Length == 0)
                    {
                        continue;
                    }
                    else if ("shutdown".Equals(input, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }

                    var cmd = words[0];
                    if (commands.ContainsKey(cmd))
                    {
                        commands[cmd].Execute(app, display, words);
                    }
                    else
                    {
                        display.Notify(string.Format("> Command Not Recognized. [{0}]", string.Join(" ", words)));
                    }
                }

                // This is for Mono compatability.
                input = string.Empty;
            }

            app.Stop();

            display.Notify("Press enter to quit...");
            Console.ReadLine();
        }