Example #1
0
        public void PullNotifications()
        {
            try
            {
                string name = "npp.css.dbg.notifications." + remoteProcessId;
                using (var pipeServer = new NamedPipeServerStream(name, PipeDirection.In))
                    using (var streamReader = new StreamReader(pipeServer))
                    {
                        pipeServer.WaitForConnection();
                        Notify("In.Client connected.");

                        while (true)
                        {
                            string message = streamReader.ReadLine();

                            if (message == NppCommand.Exit || message == null)
                            {
                                break;
                            }

                            MessageQueue.AddNotification(message);
                        }
                    }
            }
            catch (IOException e)
            {
                Notify("ERROR: " + e.Message);
            }

            Notify("In.Client disconnected.");
        }
Example #2
0
        void PushCommands()
        {
            try
            {
                string name = "npp.css.dbg.commands." + remoteProcessId;
                using (var pipeServer = new NamedPipeServerStream(name, PipeDirection.Out))
                    using (var streamWriter = new StreamWriter(pipeServer))
                    {
                        pipeServer.WaitForConnection();
                        Notify("Out.Client connected.");
                        streamWriter.AutoFlush = true;

                        while (true)
                        {
                            string command = MessageQueue.WaitForCommand();

                            streamWriter.WriteLine(command);
                            if (command == NppCommand.Exit)
                            {
                                MessageQueue.AddNotification(NppCommand.Exit); //signal to stop the PullNotifications channel
                                break;
                            }
                            pipeServer.WaitForPipeDrain();
                        }
                    }
            }
            catch
            {
            }

            Notify("Out.Client disconnected.");
        }
Example #3
0
        static void WaitForExit(Process debugger)
        {
            debugger.WaitForExit();

            debuggeeProcessId     =
                debuggerProcessId = 0;

            MessageQueue.AddCommand(NppCommand.Exit);

            if (OnDebuggerStateChanged != null)
            {
                OnDebuggerStateChanged();
            }

            MessageQueue.AddNotification(NppCategory.Diagnostics + debugger.Id + ":STOPPED");
        }
Example #4
0
        static public bool Start()
        {
            if (!initialized)
            {
                Init();
            }

            if (debuggerProcessId != 0)
            {
                return(false);
            }

            MessageQueue.Clear();

            string debuggerDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string debuggerApp = Path.Combine(debuggerDir, "mdbghost_64.exe");
            var    debugger    = Process.Start(new ProcessStartInfo
            {
                //FileName = debuggerApp,
                FileName = Path.Combine(debuggerDir, "mdbg.exe"),
                //FileName = @"c:\program files (x86)\notepad++\plugins\csscriptnpp\mdbg\mdbghost_64.exe",
                Arguments = "!load npp.dll",
                //CreateNoWindow = true,
                //UseShellExecute = false
            });

            MessageQueue.AddNotification(NppCategory.Diagnostics + debugger.Id + ":STARTED");
            debuggerProcessId = debugger.Id;

            Task.Factory.StartNew(() => WaitForExit(debugger));

            channel        = new RemoteChannelServer(debuggerProcessId);
            channel.Notify = message => Console.WriteLine(message);
            channel.Start();

            return(true);
        }