コード例 #1
0
        static int Main()
        {
            StaticConfiguration.Initialize();
            StaticConfiguration.Start();

            FakeDhcpServer fakeDhcpServer = new FakeDhcpServer();
            DebugAdapter   adapter        = new DebugAdapter(fakeDhcpServer);

            Console.WriteLine("Created Debug Adapter {0}",
                              adapter.HardwareAddress);
            Core.Instance().RegisterAdapter(adapter, 64);

            DhcpClient dc = new DhcpClient(adapter);

            dc.Start();

            while (fakeDhcpServer.State == FakeDhcpServer.ServerState.Running)
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }
            dc.Stop();

            Console.WriteLine("Removing Adapter.");
            Core.Instance().DeregisterAdapter(adapter);

            StaticConfiguration.Stop();

            if (fakeDhcpServer.State == FakeDhcpServer.ServerState.Failed)
            {
                return(1);
            }
            return(0);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Lichen9618/neo-debugger
        private void OnExecute(CommandLineApplication app, IConsole console)
        {
            if (Debug)
            {
                System.Diagnostics.Debugger.Launch();
            }

            var adapter = new DebugAdapter(
                Console.OpenStandardInput(),
                Console.OpenStandardOutput(),
                DebugExecutionEngine.Create,
                Crypto.Hash160,
                (cat, msg) => LogMessage(msg, cat));

            adapter.Run();
        }
コード例 #3
0
 public DebugAdapterWebSocketConnection()
 {
     Server = new DebugAdapter(null, null, Channel, null);
 }
コード例 #4
0
        async Task ListenForMessages()
        {
            this.messageLoopSyncContext = SynchronizationContext.Current;

            // Ensure that the console is using UTF-8 encoding
            System.Console.InputEncoding = Encoding.UTF8;
            System.Console.OutputEncoding = Encoding.UTF8;

            // Open the standard input/output streams
            this.inputStream = System.Console.OpenStandardInput();
            this.outputStream = System.Console.OpenStandardOutput();

            IMessageSerializer messageSerializer = null;
            IMessageProcessor messageProcessor = null;

            // Use a different serializer and message processor based
            // on whether this instance should host a language server
            // debug adapter.
            if (this.runDebugAdapter)
            {
                DebugAdapter debugAdapter = new DebugAdapter();
                debugAdapter.Initialize();

                messageProcessor = debugAdapter;
                messageSerializer = new V8MessageSerializer();
            }
            else
            {
                // Set up the LanguageServer
                LanguageServer languageServer = new LanguageServer();
                languageServer.Initialize();

                messageProcessor = languageServer;
                messageSerializer = new JsonRpcMessageSerializer();
            }

            // Set up the reader and writer
            this.messageReader = 
                new MessageReader(
                    this.inputStream,
                    messageSerializer);

            this.messageWriter = 
                new MessageWriter(
                    this.outputStream,
                    messageSerializer);

            // Set up the console host which will send events
            // through the MessageWriter
            this.consoleHost = new StdioConsoleHost(messageWriter);

            // Set up the PowerShell session
            this.editorSession = new EditorSession();
            this.editorSession.StartSession(this.consoleHost);
            this.editorSession.PowerShellContext.OutputWritten += powerShellContext_OutputWritten;

            if (this.runDebugAdapter)
            {
                // Attach to debugger events from the PowerShell session
                this.editorSession.DebugService.DebuggerStopped += DebugService_DebuggerStopped;
            }

            // Run the message loop
            bool isRunning = true;
            while (isRunning)
            {
                Message newMessage = null;

                try
                {
                    // Read a message from stdin
                    newMessage = await this.messageReader.ReadMessage();
                }
                catch (MessageParseException e)
                {
                    // TODO: Write an error response

                    Logger.Write(
                        LogLevel.Error,
                        "Could not parse a message that was received:\r\n\r\n" +
                        e.ToString());

                    // Continue the loop
                    continue;
                }

                // Process the message
                await messageProcessor.ProcessMessage(
                    newMessage,
                    this.editorSession,
                    this.messageWriter);
            }
        }
コード例 #5
0
 public DebugController(DebugAdapter adapter, DebugBot bot)
 {
     _adapter = adapter;
     _bot     = bot;
 }
コード例 #6
0
 public void RegisterAdapter(DebugAdapter adapter)
 {
     this.adapter = adapter;
 }