protected virtual void OnPseudoTerminalRequested(PseudoTerminalRequestedEventArgs e)
 {
     if (PseudoTerminalRequested != null)
     {
         PseudoTerminalRequested(this, e);
     }
 }
        protected override void OnPseudoTerminalRequested(PseudoTerminalRequestedEventArgs e)
        {
            // Check type of terminal.
            switch (e.TerminalName)
            {
                case "xterm":
                    _terminal = new XtermTerminal();
                    break;
                default:
                    e.Success = false;
                    return;
            }

            e.Success = true;
        }
        protected internal override void ProcessRequest(string requestType, bool wantReply,
                                                        SshStreamReader msgReader)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            switch (requestType)
            {
            case "pty-req":
                // Read information about pseudo-terminal.
                var termEnvVar       = msgReader.ReadString();
                var termCharsWidth   = msgReader.ReadUInt32();
                var termCharsHeight  = msgReader.ReadUInt32();
                var termPixelsWidth  = msgReader.ReadUInt32();
                var termPixelsHeight = msgReader.ReadUInt32();
                var termModes        = ReadTerminalModes(msgReader.ReadByteString());

                // Raise event to request pseudo terminal.
                var pseudoTerminalRequestedEventArgs = new PseudoTerminalRequestedEventArgs(termEnvVar);

                OnPseudoTerminalRequested(pseudoTerminalRequestedEventArgs);

                // Check if request to allocate pseudo terminal failed.
                if (!pseudoTerminalRequestedEventArgs.Success)
                {
                    break;
                }

                _termEnvVar       = termEnvVar;
                _termCharsWidth   = termCharsWidth;
                _termCharsHeight  = termCharsHeight;
                _termPixelsWidth  = termPixelsWidth;
                _termPixelsHeight = termPixelsHeight;
                _termModes        = termModes;

                // Add TERM to list of environment variables.
                _envVars.Add("TERM", _termEnvVar);

                // Raise event, pseudo terminal has been allocated.
                OnPseudoTerminalAllocated(new EventArgs());

                if (wantReply)
                {
                    _connService.SendMsgChannelSuccess(this);
                }
                return;

            case "env":
                // Read name and value of environment variable.
                var varName  = msgReader.ReadString();
                var varValue = msgReader.ReadString();

                // Add variable to list.
                _envVars.Add(varName, varValue);

                if (wantReply)
                {
                    _connService.SendMsgChannelSuccess(this);
                }
                return;

            case "shell":
                // Start default shell.
                StartShell();

                if (wantReply)
                {
                    _connService.SendMsgChannelSuccess(this);
                }
                return;

            case "exec":
                // not implemented

                break;

            default:
                base.ProcessRequest(requestType, wantReply, msgReader);
                return;
            }

            // Request has failed.
            if (wantReply)
            {
                _connService.SendMsgChannelFailure(this);
            }
        }
 protected virtual void OnPseudoTerminalRequested(PseudoTerminalRequestedEventArgs e)
 {
     if (PseudoTerminalRequested != null) PseudoTerminalRequested(this, e);
 }
        protected internal override void ProcessRequest(string requestType, bool wantReply,
            SshStreamReader msgReader)
        {
            if (_isDisposed) throw new ObjectDisposedException(this.GetType().FullName);

            switch (requestType)
            {
                case "pty-req":
                    // Read information about pseudo-terminal.
                    var termEnvVar = msgReader.ReadString();
                    var termCharsWidth = msgReader.ReadUInt32();
                    var termCharsHeight = msgReader.ReadUInt32();
                    var termPixelsWidth = msgReader.ReadUInt32();
                    var termPixelsHeight = msgReader.ReadUInt32();
                    var termModes = ReadTerminalModes(msgReader.ReadByteString());

                    // Raise event to request pseudo terminal.
                    var pseudoTerminalRequestedEventArgs = new PseudoTerminalRequestedEventArgs(termEnvVar);

                    OnPseudoTerminalRequested(pseudoTerminalRequestedEventArgs);

                    // Check if request to allocate pseudo terminal failed.
                    if (!pseudoTerminalRequestedEventArgs.Success) break;

                    _termEnvVar = termEnvVar;
                    _termCharsWidth = termCharsWidth;
                    _termCharsHeight = termCharsHeight;
                    _termPixelsWidth = termPixelsWidth;
                    _termPixelsHeight = termPixelsHeight;
                    _termModes = termModes;

                    // Add TERM to list of environment variables.
                    _envVars.Add("TERM", _termEnvVar);

                    // Raise event, pseudo terminal has been allocated.
                    OnPseudoTerminalAllocated(new EventArgs());

                    if (wantReply) _connService.SendMsgChannelSuccess(this);
                    return;

                case "env":
                    // Read name and value of environment variable.
                    var varName = msgReader.ReadString();
                    var varValue = msgReader.ReadString();

                    // Add variable to list.
                    _envVars.Add(varName, varValue);

                    if (wantReply) _connService.SendMsgChannelSuccess(this);
                    return;
                case "shell":
                    // Start default shell.
                    StartShell();

                    if (wantReply) _connService.SendMsgChannelSuccess(this);
                    return;
                case "exec":
                    // not implemented

                    break;
                default:
                    base.ProcessRequest(requestType, wantReply, msgReader);
                    return;
            }

            // Request has failed.
            if (wantReply) _connService.SendMsgChannelFailure(this);
        }