Esempio n. 1
0
        public void StartHost()
        {
            if (Main == null)
            {
                throw new InvalidOperationException(" 'Main' was null!");
            }

            var terminal = new ConsoleTerminal();

            fakeSession = new ConsoleSession(this, terminal);
            _sessions.Add(fakeSession);

            cont = true;

            var e = new SessionEventArgs(fakeSession);

            SessionDisconnected(this, e);

            if (e.RefuseConnection == false)
            {
                console_listener =
                    Task.Run(
                        () =>
                {
                    while (cont)
                    {
                        var win32_console_key = Console.ReadKey();
                        terminal.ProcessKey(keyInfo(win32_console_key));
                    }
                }

                        );

                Main(terminal);
                terminal.SendCloseRequest();
            }
            else
            {
                fakeSession.Kick();
            }
            SessionDisconnected(this, new SessionEventArgs(fakeSession));
        }
Esempio n. 2
0
 public ConsoleSession(ConsoleHost h, ConsoleTerminal term)
 {
     Host     = h;
     Terminal = term;
 }