public ThreadSupervisor(
     ExtendedManualResetEvent InBackThreadEndFlag, RunLogListBox InRunLog)
 {
     mRunLog              = new RunLogListBox(InRunLog, "Supervisor");
     mBackThreadEndFlag   = InBackThreadEndFlag;
     mCurrentReadBuffer   = null;
     mDisplacedBufferList = new List <ReadBuffer>();
     mCommandThreadList   = new List <CommandThread>();
 }
Пример #2
0
        // -------------------------------- Login -------------------------------------
        public static string[] Login(
            TelnetConnection InConn, LoginProperties InProps, RunLogListBox InRunLog)
        {
            RunLogListBox runLog = new RunLogListBox(InRunLog, "Login");

            string[] respLines =
                TelnetCore.Login(InConn, runLog, InProps.LoginUser, InProps.LoginPass, 500);

            return(respLines);
        }
Пример #3
0
 public CommandThread(
     ThreadSupervisor InSupervisor, TelnetConnection InConn,
     TelnetCommandRoute InCommandRoute,
     RunLogListBox InRunLog)
 {
     mShutdownFlag = new ExtendedManualResetEvent(false);
     mConn         = InConn;
     mCommandRoute = InCommandRoute;
     mRunLog       = InRunLog;
     Supervisor    = InSupervisor;
 }
        public void AssureReceiveThread(
            TelnetConnection InConn, RunLogListBox InRunLog)
        {
            if (RunningReceiveThread == null)
            {
                AutoResetEvent startReceivingEvent;

                // start the receive from telnet server thread.
                ThreadCommon.StartReceiveFromTelnetServerThread(
                    //          out receiveQueue,
                    out startReceivingEvent, InConn,
                    this,
                    mBackThreadEndFlag, InRunLog);
            }
        }
Пример #5
0
        public ReceiveThread(
            TelnetConnection InConn,
            AutoResetEvent InStartReceivingEvent,
            ThreadSupervisor InSupervisor,
            ExtendedManualResetEvent InShutdownFlag,
            RunLogListBox InRunLog)
        {
            mConn = InConn;

            mSupervisor = InSupervisor;
            mSupervisor.AssignRunningReceiveThread(this);

            mStartReceivingEvent = InStartReceivingEvent;
            mRunLog       = new RunLogListBox(InRunLog, "ReceiveThread");
            mShutdownFlag = InShutdownFlag;
        }
Пример #6
0
        // ----------------------------- RunCommand ------------------------------------
        public static void RunCommand(
            ThreadSupervisor InSupervisor,
            TelnetConnection InConn, TelnetCommandRoute InCommandRoute,
            RunLogListBox InRunLog,
            string InCmdText)
        {
            {
                RunLogListBox runLog = new RunLogListBox(InRunLog, "RunCommand");
                CommandThread ct     = new CommandThread(
                    InSupervisor, InConn, InCommandRoute, InRunLog);
                ct.CommandText = InCmdText;

                // run the logout thread.
                CommandThread.ThreadStart(ct);
            }
        }
Пример #7
0
        // --------------------------------- Login ------------------------------
        public static string[] Login(
            TelnetConnection InConn, RunLogListBox InRunLog,
            string InUserName, string InPass, int InLoginTimeOutMs)
        {
            string s = null;

            int cx = 0;

            while (true)
            {
                InRunLog.Write("Read login prompt ...");
                s = InConn.Read(InLoginTimeOutMs);
                if (s.Length > 0)
                {
                    break;
                }
                cx += 1;
                if (cx > 5)
                {
                    throw new Exception("Did not receive any login prompt text from telnet server");
                }
            }

            if (!s.TrimEnd().EndsWith(":"))
            {
                throw new Exception("Failed to connect : no login prompt");
            }
            InRunLog.Write("Username " + InUserName);
            InConn.WriteLine(InUserName);

            s += InConn.Read(InLoginTimeOutMs);
            if (!s.TrimEnd().EndsWith(":"))
            {
                throw new Exception("Failed to connect : no password prompt");
            }
            InRunLog.Write("Password " + InPass);
            InConn.WriteLine(InPass);

            s += InConn.Read(InLoginTimeOutMs);

            string[] lines = SplitReadText(s);

            return(lines);
        }
Пример #8
0
        // ---------------------- StartReceiveFromTelnetServerThread ----------------------
        public static void StartReceiveFromTelnetServerThread(
            //      out DataQueue OutReceiveDataQueue,
            out AutoResetEvent OutStartReceivingEvent,
            TelnetConnection InConn, ThreadSupervisor InSupervisor,
            ExtendedManualResetEvent InShutdownFlag, RunLogListBox InRunLog)
        {
            // create the event that the receive thread listens to to be signaled that it
            // should wake up and receive from the telnet server.
            OutStartReceivingEvent = new AutoResetEvent(false);

            // setup the ReceiveThread object with all the object references it needs.
            ReceiveThread rt = new ReceiveThread(
                InConn,
                OutStartReceivingEvent,
                InSupervisor,
                InShutdownFlag, InRunLog);

            // start the ReceiveThread.
            ReceiveThread.ThreadStart(rt);
        }