コード例 #1
0
        /// <summary>
        /// Wait and read ReadBuffer contents until the read text ends with
        /// the pattern.
        /// </summary>
        /// <param name="InPattern"></param>
        /// <returns></returns>
        public string[] ReadUntilEndsWith(string[] InAnyPattern)
        {
            StringBuilder accum = new StringBuilder();

            while (true)
            {
                // extract whatever text there is in the ReadBuffer.
                // ( the ReceiveThread appends to this buffer as data arrives from the
                //   telnet server. )
                lock (LockFlag)
                {
                    accum.Append(Buffer.ToString());
                    Buffer.Length = 0;
                    GotDataEvent.Reset();
                }

                // check for the "ends with" pattern.
                if (accum.ToString().TrimEnd().EndsWithAny(InAnyPattern) == true)
                {
                    break;
                }

                // wait for more data to arrive and be placed in the read buffer.
                GotDataEvent.WaitOne();
            }

            string[] lines = TelnetCore.SplitReadText(accum.ToString());
            return(lines);
        }
コード例 #2
0
        /// <summary>
        /// Wait and read whatever is in the ReadBuffer.
        /// </summary>
        /// <param name="InPattern"></param>
        /// <returns></returns>
        public string[] Read()
        {
            StringBuilder accum = new StringBuilder();

            while (true)
            {
                // extract whatever text there is in the ReadBuffer.
                // ( the ReceiveThread appends to this buffer as data arrives from the
                //   telnet server. )
                lock (LockFlag)
                {
                    accum.Append(Buffer.ToString());
                    Buffer.Length = 0;
                    GotDataEvent.Reset();
                }

                // leave when there is something there.
                if (accum.Length > 0)
                {
                    break;
                }

                // wait for more data to arrive and be placed in the read buffer.
                GotDataEvent.WaitOne();
            }

            string[] lines = TelnetCore.SplitReadText(accum.ToString());
            return(lines);
        }
コード例 #3
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);
        }