Beispiel #1
0
        public void ConnectionLost(Exception ex)
        {
            Console.Out.WriteLine("Lost our connection! Exception: " + ex.Message);
            log.Warn("Lost our connection!", ex);

            int delay = 500;
            while (true)
                try
                {
                    if (tcpClient != null)
                        tcpClient.Close();
                    tcpClient = new TcpClient();
                    tcpClient.Start(this, ipAddress);

                    ConnectToServer();
                    Console.Out.WriteLine("Re-connected");
                    log.Warn("Re-connected");
                    return;
                }
                catch (Exception e)
                {
                    log.Warn("Re-connection fails!", e);
                    Console.Out.WriteLine("Re-connection fails! Exception: " + e.Message);
                    Thread.Sleep(delay);
                    delay += 500;
                }
        }
Beispiel #2
0
        private void Run()
        {
            Console.Out.WriteLine("starting...");

            tcpClient = new TcpClient();
            tcpClient.Start(this, ipAddress);
            ConnectToServer();

            // It's all messages to us now.
            Console.Out.WriteLine("enter \"exit\" to exit program");
            while (true)
            {
                string line = Console.ReadLine();
                if (line == "exit")
                    break;
            }
        }