コード例 #1
0
        public MeshCentralTerminal(MeshCentralTunnel parent, int protocol, int width, int height)
        {
            this.parent   = parent;
            this.protocol = protocol;
            this.width    = width;
            this.height   = height;

            // Start the capture thread
            mainThread = new Thread(new ThreadStart(MainTerminalLoop));
            mainThread.Start();
        }
コード例 #2
0
 public void Dispose()
 {
     if (process != null)
     {
         try { Process p = Process.GetProcessById(process.ProcessInfo.dwProcessId); if (p.HasExited == false)
               {
                   p.Kill();
               }
         } catch (Exception) { }
         try { process.Dispose(); } catch (Exception) { }
         process = null;
     }
     inputPipe     = null;
     outputPipe    = null;
     pseudoConsole = null;
     writer        = null;
     mainThread    = null;
     parent        = null;
 }
コード例 #3
0
 /// <summary>
 /// Reads PseudoConsole output and copies it to the terminal's standard out.
 /// </summary>
 /// <param name="outputReadSide">the "read" side of the pseudo console output pipe</param>
 private static void CopyPipeToOutput(SafeFileHandle outputReadSide, MeshCentralTunnel tunnel)
 {
     byte[] buffer = new byte[1024];
     using (var pseudoConsoleOutput = new FileStream(outputReadSide, FileAccess.Read))
     {
         while (true)
         {
             int len = 0;
             try { len = pseudoConsoleOutput.Read(buffer, 0, buffer.Length); } catch (Exception) { }
             if (len == 0)
             {
                 tunnel.disconnect(); return;
             }
             if (tunnel.WebSocket != null)
             {
                 try { tunnel.WebSocket.SendBinary(buffer, 0, len); } catch (Exception) { }
             }
         }
     }
 }