Example #1
0
 public void close()
 {
     if (_session != null)
     {
         _session.InternalTerminate();
     }
     if (_connector != null)
     {
         if (typeof(SSHConnector) == _connector.GetType())
         {
             ((SSHConnector)_connector).Result.Close();
         }
         else
         {
             ((TelnetConnector)_connector).Result.Close();
         }
     }
     if (tcp != null)
     {
         tcp = null;
     }
     if (ssh != null)
     {
         ssh = null;
     }
     if (_param != null)
     {
         _param = null;
     }
     _connector   = null;
     _session     = null;
     _isConnected = false;
     _timedOut    = false;
 }
Example #2
0
        void OnTimer(object sender, EventArgs args)
        {
            //TODO ƒAƒvƒŠƒP[ƒVƒ‡ƒ““à•”ƒCƒxƒ“ƒgƒƒO‚Å‚àì‚Á‚Ä‚±‚¤‚¢‚¤‚Ì‚Í‹L˜^‚µ‚Ä‚¢‚­‚Ì‚ª‚¢‚¢‚Ì‚©H
            //foreach(ISession s in TerminalEmulatorPlugin.Instance.GetSessionManager().AllSessions) {
            //    IAbstractTerminalHost ts = (IAbstractTerminalHost)s.GetAdapter(typeof(IAbstractTerminalHost));
            //    if (ts != null && ts.TerminalConnection != null && ts.TerminalConnection.TerminalOutput != null) {
            //        ts.TerminalConnection.TerminalOutput.SendKeepAliveData();
            //    }
            //}

            /* //removed 25.06.2015
             * if(_parent.GetType() == typeof(TerminalEmulatorPlugin)) {
             *  //((TerminalEmulatorPlugin)_parent).KeepAlive;
             * }
             * else */
            if (_parent.GetType() == typeof(TerminalSession))  //ITerminalSession
            {
                TerminalSession ts = (TerminalSession)_parent;
                if (ts != null && ts.TerminalConnection != null && ts.TerminalConnection.TerminalOutput != null)
                {
                    ts.TerminalConnection.TerminalOutput.SendKeepAliveData();
                }
            }
        }
Example #3
0
        public bool StartConnection()
        {
            bool bConResult = false;

            _isConnected = false;

            /*if (_session != null)
             *  if (_session.TerminalConnection != null)
             *      _isConnected = _session.TerminalConnection.IsClosed;
             */
            if (_Console == null)
            {
                _Console = new ConsoleMain();
            }
            //ISynchronizedConnector synchCon = _Console.CreateSynchronizedConnector(null);

            if (ssh != null)
            {
                _connector = _Console.AsyncSSHConnect(this /* synchCon.InterruptableConnectorClient */, ssh);
            }
            else
            {
                _connector = _Console.AsyncTelnetConnect(this /* synchCon.InterruptableConnectorClient */, tcp);
            }

            if (_connector == null)
            {
                _isRunning = false;
                return(bConResult);
            }

            //_result = synchCon.WaitConnection(_connector, _timeout * 1000);
            while ((!_timedOut) && (!_isConnected))
            {
                Thread.Sleep(100);
            }

            _result = ((InterruptableConnector)_connector).Result;
            if (_result == null)
            {
                _connector = null;
                _isRunning = false;
                return(bConResult);
            }

            try
            {
                _session         = new TerminalSession(((InterruptableConnector)_connector).Result, _terminalSettings, _terminalOptions);
                _session._parent = this;
                //SessionHost host = new SessionHost(this, session);
                _session.InternalStart();  // => _output.Connection.Socket.RepeatAsyncRead(_terminal);
                bConResult = true;
            }
            catch (Exception ex)
            {
                bConResult = false;
                if (_debug > 0)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            return(bConResult);
        }