Example #1
0
 public void Resize(int width, int height)
 {
     if (!_parent.IsClosed)
     {
         TelnetOptionWriter wr = new TelnetOptionWriter();
         wr.WriteTerminalSize(width, height);
         wr.WriteTo(_socket);
     }
 }
Example #2
0
        private void ProcessOptionRequest(byte option_)
        {
            TelnetOption option = (TelnetOption)option_;

            switch (option)
            {
            case TelnetOption.TerminalType:
                if (_state == TelnetCode.DO)
                {
                    _optionWriter.Write(TelnetCode.WILL, option);
                }
                else
                {
                    _warnings.Add(PEnv.Strings.GetString("Message.Telnet.FailedToSendTerminalType"));
                }
                break;

            case TelnetOption.NAWS:
                if (_state == TelnetCode.DO)
                {
                    _optionWriter.WriteTerminalSize(_width, _height);
                }
                else
                {
                    _warnings.Add(PEnv.Strings.GetString("Message.Telnet.FailedToSendWidnowSize"));
                }
                break;

            case TelnetOption.SuppressGoAhead:
                if (_state != TelnetCode.WILL && _state != TelnetCode.DO)     //!!両方が来たことを確認する
                {
                    _warnings.Add(PEnv.Strings.GetString("Message.Telnet.FailedToSendSuppressGoAhead"));
                }
                break;

            case TelnetOption.LocalEcho:
                if (_state == TelnetCode.DO)
                {
                    _optionWriter.Write(TelnetCode.WILL, option);
                }
                break;

            default:     //上記以外はすべて拒否。DOにはWON'T, WILLにはDON'Tの応答を返す。
                if (_state == TelnetCode.DO)
                {
                    _optionWriter.Write(TelnetCode.WONT, option);
                }
                else if (_state == TelnetCode.WILL)
                {
                    _optionWriter.Write(TelnetCode.DONT, option);
                }
                break;
            }
        }
 public void Resize(int width, int height)
 {
     if (!_parent.IsClosed) {
         TelnetOptionWriter wr = new TelnetOptionWriter();
         wr.WriteTerminalSize(width, height);
         wr.WriteTo(_socket);
     }
 }