Ejemplo n.º 1
0
        public static void CreatePipes(out ConsoleMirror server, out ConsoleMirror client)
        {
            var input  = UnixPipes.CreatePipes();
            var output = UnixPipes.CreatePipes();
            var err    = UnixPipes.CreatePipes();

            server = new ConsoleMirror {
                Input = input.Reading, Output = output.Writing, Error = err.Writing
            };
            client = new ConsoleMirror {
                Input = input.Writing, Output = output.Reading, Error = err.Reading
            };
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            interruptPipe = UnixPipes.CreatePipes();
            UnixSignal[] signals = new UnixSignal[] {
                new UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
                new UnixSignal(Mono.Unix.Native.Signum.SIGINT),
            };
            Thread signalThread = new Thread(delegate()
            {
                int index = UnixSignal.WaitAny(signals);
                interruptPipe.Writing.Write(BitConverter.GetBytes(index), 0, 4);
            });

            signalThread.IsBackground = true;
            signalThread.Start();
            MainAsync(args).ConfigureAwait(false).GetAwaiter().GetResult();
        }
Ejemplo n.º 3
0
        public ClientCore()
        {
            s_clientCore = this;

            //Ansi.SendAnsiInit();

            m_synchronizedInvoke = new SynchronizedInvoke();

            // Services
            m_baseServicesDispatcher = new BaseServicesDispatcher();

            // Init console
            m_textConsole = new TextConsole();
            ChiConsole.SetChiConsole(m_textConsole);

            // Initialize ironpython
            IronPython.Compiler.Options.GenerateModulesAsSnippets = true;
            m_pythonEngine = new PythonEngine();

            ChiPythonStream s = new ChiPythonStream();

            m_pythonEngine.SetStandardOutput(s);
            m_pythonEngine.SetStandardError(s);
            m_pythonEngine.SetStandardInput(s);
            //m_pythonEngine.AddToPath(Environment.CurrentDirectory);
            //m_pythonEngine.AddToPath(Application.StartupPath + "/lib");
#if DEBUG
            m_pythonEngine.AddToPath(@"../../../scripts/lib");
#endif
            m_pythonEngine.LoadAssembly(typeof(TriggerManager).Assembly);             // load BatClientBase
            m_pythonEngine.LoadAssembly(typeof(System.Drawing.Bitmap).Assembly);      // load System.Drawing
            m_pythonEngine.LoadAssembly(typeof(System.Windows.Forms.Keys).Assembly);  // load System.Windows.Forms



            // Network
            m_telnet = new Telnet();
            m_telnet.connectEvent    += new Telnet.ConnectDelegate(_ConnectEvent);
            m_telnet.disconnectEvent += new Telnet.DisconnectDelegate(_DisconnectEvent);
            m_telnet.receiveEvent    += new Telnet.ReceiveDelegate(_ReceiveEvent);
            m_telnet.promptEvent     += new Telnet.PromptDelegate(_PromptEvent);
            m_telnet.telnetEvent     += new Telnet.TelnetDelegate(_TelnetEvent);

            m_netPipe = UnixPipes.CreatePipes();


            m_commandManager = new CommandManager(m_baseServicesDispatcher);
            AddBuiltinCommands();

            m_triggerManager = new TriggerManager(m_baseServicesDispatcher);

            m_keyManager = new KeyManager(m_baseServicesDispatcher);

            m_hiliteManager = new HiliteManager(m_triggerManager);

            PythonInterface.Initialize(m_baseServicesDispatcher, m_triggerManager, m_commandManager, this,
                                       m_textConsole, m_pythonEngine, m_keyManager, m_hiliteManager);

            // run init script

            Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            Version baseVersion    = System.Reflection.Assembly.GetAssembly(typeof(Telnet)).GetName().Version;
            ChiConsole.WriteLine("Chiroptera version {0} (base {1})", currentVersion.ToString(2), baseVersion.ToString(2));
            ChiConsole.WriteLine("Using {0}", PythonEngine.VersionString);

            try
            {
#if DEBUG
                PythonInterface.RunScript(Path.GetFullPath("../../../scripts/std/init_std.bc"));
#else
                PythonInterface.RunScript(Path.Combine(Environment.CurrentDirectory, "std/init_std.bc"));
#endif
            }
            catch (Exception e)
            {
                ChiConsole.WriteError("Error running init_std.bc", e);
            }

/*
 *                      m_pythonEngine.Import("site");
 *
 *                      try
 *                      {
 *                              m_pythonEngine.ExecuteFile("init.py");
 *                      }
 *                      catch (Exception e)
 *                      {
 *                              ChiConsole.WriteError("Eval failed", e);
 *                      }
 */
        }