Subject: Reconnecting a Virtual Terminal
Date: 2020-05-22 02:04:20
From: Justin
Source: reconnecting-virtual-terminal
----------------------------------------------------------------------

Hello Support,

I am building an app that will wake up, connect to a terminal server, do some work, sleep and then repeat. I can get it to run once without issue. However, when I create the second set of TelnetClient and VirtualTerminal classes, it will connect but it won't update the internal screen.  What am I doing wrong?

The relevant code is below 



        public void Connect(string server, int port)
        {
            Server = server;
            Port = port;
            emulatorStateChanged(MinxEmulatorStates.Connecting);

            telnetClient = new TelnetClient(server, port);

            tControl = new VirtualTerminal(telnetClient);
            tControl.NewLineType = ComponentPro.Net.Terminal.TerminalNewLineType.CRLF;
            tControl.KeysMode = ComponentPro.Net.Terminal.TerminalKeysMode.VT100Plus;
            tControl.StateChanged  = new System.EventHandler(this.tControl_StateChanged);

            telnetClient.CreateShellCompleted  = TelnetClient_CreateShellCompleted;
            telnetClient.CreateShellAsync();
        }

        private void TelnetClient_CreateShellCompleted(object sender, ComponentPro.ExtendedAsyncCompletedEventArgs e)
        {
            MinxLogger.WriteEntry(MinxLogger.MinxLoggerType.Debug, "Emulator tControl state changed: ");
            if((e.Cancelled) || (e.Error != null) || (e.Result == null))
            {
                Stop();
                emulatorStateChanged(MinxEmulatorStates.Disconnected);
            }
            else
            {
                terminalShell = e.Result;
                terminalShell.Timeout = Timeout;
                Run();
                emulatorStateChanged(MinxEmulatorStates.Connected);
            }
        }

        public void Disconnect()
        {
            VirtualTerminal term = null;
            if (terminalShell != null)
            {
                terminalShell.Close();
                terminalShell = null;
            }

            if (tControl != null)
            {
                tControl.Screen.Clear(); 
                tControl.Dispose();

            }

            if(telnetClient != null)
            {
                telnetClient = null;
            }

            emulatorStateChanged(MinxEmulatorStates.Disconnected);
        }

----------------------------------------------------------------------

Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index