Exemplo n.º 1
0
        public void ShellDataEventArgsConstructorTest1()
        {
            string             line   = string.Empty; // TODO: Initialize to an appropriate value
            ShellDataEventArgs target = new ShellDataEventArgs(line);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemplo n.º 2
0
        void sshShellStream_DataReceived(object sender, ShellDataEventArgs e)
        {
            bool useStream = false;

            if (useStream)
            {
                string s = srOutput.ReadToEnd();
                foreach (char c in s)
                {
                    //the base class provides for this
                    doCharRecieved(c);
                }
            }
            else
            {
                char[] chars = Encoding.ASCII.GetChars(e.Data);
                for (int i = 0; i < chars.Length; i++)
                {
                    //the base class provides for this
                    doCharRecieved(chars[i]);
                }

                //srOutput.ReadToEnd();
            }
        }
Exemplo n.º 3
0
        public void ShellDataEventArgsConstructorTest()
        {
            byte[]             data   = null; // TODO: Initialize to an appropriate value
            ShellDataEventArgs target = new ShellDataEventArgs(data);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemplo n.º 4
0
        //************************************* EVENT HANDLERS

        private void StreamDataReceivedHandler(object sender, ShellDataEventArgs e)
        {
            var    stream       = (ShellStream)sender;
            string dataReceived = "";

            //Debug("Received Data. Length: " + stream.Length);

            // Loop as long as there is data on the stream
            while (stream.DataAvailable)
            {
                dataReceived = stream.Read();
            }

            if (dataReceived != "")
            {
                if (dataReceived.Length > 250)
                {
                    // Split into 250 character chunks for Simpl Windows
                    IEnumerable <string> dataReceivedArray = SplitDataReceived(dataReceived, 250);

                    // Return each chunk separately
                    foreach (var str in dataReceivedArray)
                    {
                        ReceivedData(str);
                    }
                }
                else
                {
                    ReceivedData(dataReceived);
                }
            }
        }
 //convert event from ssh event to string data
 private void ReceiverData(Object o, ShellDataEventArgs e)
 {
     if (this.reveiverDataAction != null)
     {
         this.reveiverDataAction.DynamicInvoke(o, System.Text.Encoding.ASCII.GetString(e.Data));
     }
 }
Exemplo n.º 6
0
 private void SshStream_DataReceived(object sender, ShellDataEventArgs e)
 {
     if (outputBox.InvokeRequired)
     {
         outputBox.Invoke(new delegateUpdate(UpdateOutput));
     }
     delay = delayMeasurer.ElapsedMilliseconds;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Receive data from SSH client and send to updates pipe for processing by web client
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void ShellStream_DataReceived(object sender, ShellDataEventArgs e)
 {
     try
     {
         pipeMessaging.SendUpdatesPipeMessage("term|" + Encoding.UTF8.GetString(e.Data));
     }
     catch (Exception exc)
     {
         Trace.TraceError("Failed to process terminal updates, remote session {0} ({1})", RemoteSessionID, exc);
         pipeMessaging.ClosePipes();
     }
 }
Exemplo n.º 8
0
    private void Stream_DataReceived(object?sender, ShellDataEventArgs e)
    {
        if (e.Data.Length >= 1)
        {
            var fifo = this.PipePoint.StreamWriter;

            ReadOnlyMemory <byte>[]? recvList = new ReadOnlyMemory <byte>[] { e.Data._CloneByte() };

            fifo.EnqueueAllWithLock(recvList);

            fifo.CompleteWrite();
        }
    }
Exemplo n.º 9
0
        private void Connect_OutputDataReceived(object sender, ShellDataEventArgs received)
        {
            string data = Encoding.UTF8.GetString(received.Data);

            data = color.Replace(data, "");
            data = lines.Replace(data, "");
            data = enter.Replace(data, "");
            connectLogBuffer.Append(data);

            if (isLogOutput == false)
            {
                return;
            }
            DisplayData();
        }
Exemplo n.º 10
0
        private void _OnDataReceived(object sender, ShellDataEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine(e.Data.Length.ToString() + " received");

            lock (Terminal)
            {
                int oldTopRow = Terminal.ViewPort.TopRow;

                Consumer.Push(e.Data);

                if (Terminal.Changed)
                {
                    Terminal.ClearChanges();

                    if (oldTopRow != Terminal.ViewPort.TopRow && oldTopRow >= ViewTop)
                    {
                        ViewTop = Terminal.ViewPort.TopRow;
                    }

                    canvas.Invalidate();
                }
            }
        }
Exemplo n.º 11
0
 private void Stream_DataReceived(object sender, ShellDataEventArgs e)
 {
     base.NotifyDataReceived(e.Data);
 }
        private static void OnShellDataRx(object sender, ShellDataEventArgs e)
        {
            var  escapeSequenceBytes = new List <byte>(128);
            var  isInEscapeSequence  = false;
            byte rxbyteprevious      = 0;
            byte escapeSequenceType  = 0;
            var  rxbuffer            = e.Data;

            foreach (var rxByte in rxbuffer)
            {
                // We've found the beginning of an escapr sequence
                if (isInEscapeSequence == false && rxByte == Escape)
                {
                    isInEscapeSequence = true;
                    escapeSequenceBytes.Clear();
                    rxbyteprevious = rxByte;
                    continue;
                }

                // Print out the character if we are not in an escape sequence and it is a printable character
                if (isInEscapeSequence == false)
                {
                    if (rxByte >= 32 || (rxByte >= 8 && rxByte <= 13))
                    {
                        if (_forwardShellStreamOutput)
                        {
                            Console.Write((char)rxByte);
                        }
                    }
                    else if (rxByte == 7)
                    {
                        if (_forwardShellStreamOutput)
                        {
                            Console.Beep();
                        }
                    }
                    else
                    {
                        if (_forwardShellStreamOutput)
                        {
                            Terminal.WriteLine($"[NPC {rxByte}]", ConsoleColor.DarkYellow);
                        }
                    }

                    rxbyteprevious = rxByte;
                    continue;
                }

                // If we are already inside an escape sequence . . .
                // Add the byte to the escape sequence
                escapeSequenceBytes.Add(rxByte);

                // Ignore the second escape byte 91 '[' or ']'
                if (rxbyteprevious == Escape)
                {
                    rxbyteprevious = rxByte;
                    if (ControlSequenceInitiators.Contains(rxByte))
                    {
                        escapeSequenceType = rxByte;
                        continue;
                    }

                    escapeSequenceType = 0;
                }

                // Detect if it's the last byte of the escape sequence (64 to 126)
                // This last character determines the command to execute
                var endOfSequenceType91 = escapeSequenceType == (byte)'[' && (rxByte >= 64 && rxByte <= 126);
                var endOfSequenceType93 = escapeSequenceType == (byte)']' && (rxByte == 7);
                if (endOfSequenceType91 || endOfSequenceType93)
                {
                    try
                    {
                        // Execute the command of the given escape sequence
                        HandleShellEscapeSequence(escapeSequenceBytes.ToArray());
                    }
                    finally
                    {
                        isInEscapeSequence = false;
                        escapeSequenceBytes.Clear();
                        rxbyteprevious = rxByte;
                    }

                    continue;
                }

                rxbyteprevious = rxByte;
            }
        }
Exemplo n.º 13
0
 private void Stream_DataReceived(object sender, ShellDataEventArgs e)
 {
 }
 private void Shell_DataReceived(object sender, ShellDataEventArgs e)
 {
     Debug.Write(Encoding.Default.GetString(e.Data));
 }
Exemplo n.º 15
0
 private void Shell_DataReceived(object sender, ShellDataEventArgs e)
 {
     this.SshHub.Clients.All.SendAsync("newSshMessage", Encoding.UTF8.GetString(e.Data));
 }
Exemplo n.º 16
0
 private void Terminal_DataReceived(object sender, ShellDataEventArgs e)
 {
     ConsoleDataReceived?.Invoke(sender, EscapeUtf8(Encoding.UTF8.GetString(e.Data)));
 }