/// <summary>
        /// This is the main CoSy client communication thread.
        /// </summary>
        /// <param name="client">The handle of the TCP client connection</param>
        private void HandleClientComm(object client)
        {
            TcpClient tcpClient = (TcpClient)client;
            TelnetStream stream = new TelnetStream(tcpClient.GetStream());
            LineBuffer buffer = new LineBuffer(stream);

            try
            {
                DateTime loginTime = DateTime.Now;

                buffer.WriteLine("CIX Conferencing System");

                while (true)
                {
                    buffer.WriteString("login: "******"qix" || loginString == "cix")
                    {
                        break;
                    }
                    buffer.WriteLine("Unknown login");
                }

                Version ver = Assembly.GetEntryAssembly().GetName().Version;
                string versionString = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
                buffer.WriteLine(string.Format("{0} {1}", Properties.Resources.CIXAPIProxyTitle, versionString));

                buffer.WriteString("Nickname? (Enter 'new' for new user) ");
                string userName = buffer.ReadLine();

                buffer.WriteString("Password: "******"");

                Console.WriteLine("Logged in as '{0}' with password '{1}'", userName, password);

                _forums = new Forums();

                buffer.WriteLine(string.Format("You are a member of {0} conference(s).", _forums.Count));
                buffer.WriteLine("Max scratchsize during file has been set to 20000000 bytes");

                TopLevelCommand(buffer);

                buffer.Output = null;

                // Round up login time to 1 minute.
                TimeSpan onlineTime = (DateTime.Now - loginTime).Add(new TimeSpan(0, 1, 0));

                buffer.WriteLine(string.Format("{0}, you have been online {1}:{2} on line 5", userName, onlineTime.Hours,
                                               onlineTime.Minutes));
                buffer.WriteLine("Goodbye from CIX     !!!HANGUP NOW!!!");
            }
            catch (IOException)
            {
                Console.WriteLine("Client terminated connection");
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Client terminated connection");
            }
            catch (AuthenticationException)
            {
                // Authentication failed. Likely the app has been revoked. Clear
                // the tokens and force re-authentication.
                Properties.Settings.Default.oauthToken = "";
                Properties.Settings.Default.oauthTokenSecret = "";

                Properties.Settings.Default.Save();
            }

            tcpClient.Close();
        }
 public LineBuffer(TelnetStream stream)
 {
     _stream = stream;
 }
Beispiel #3
0
        private bool _useCRC32; // Flag set true if using 32-bit CRC

        #endregion Fields

        #region Constructors

        public ZModem(TelnetStream stream)
        {
            _stream = stream;
        }