Exemplo n.º 1
0
 /// <summary>
 /// Connect to server
 /// </summary>
 public static void ConnectToServer()
 {
     while (true)
     {
         try
         {
             Console.WriteLine("Please wait, connecting to server...");
             client = new TcpClient();
             client.Connect(HOST, PORT);
             break;
         }
         catch (Exception exception)
         {
             Console.WriteLine(exception.Message);
             if ( InputHelper.AskQuestion( "Would you like to retry[y/n]?", new string[] { STRING_YES, STRING_NO } ) == "n" )
             {
                 Console.WriteLine("Press any key to exit...");
                 Console.ReadKey(true);
                 Environment.Exit(0);
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Connect to server
 /// </summary>
 public static void ConnectToServer()
 {
     while (true)
     {
         try
         {
             Console.WriteLine("Please wait, connecting to server...");
             client = new TcpClient();
             client.Connect(HOST, PORT);
             if (client.isConnected)
             {
                 Console.WriteLine("+ Connection established");
             }
             break;
         }
         catch (Exception exception)
         {
             Console.WriteLine(exception.Message);
             if (AskQuestion("Would you like to retry[y/n]?", new String[] { "y", "n" }) == "n")
             {
                 Console.WriteLine("Press any key to exit...");
                 Console.ReadKey(true);
                 Environment.Exit(0);
             }
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Connect to server
 /// </summary>
 public static void ConnectToServer()
 {
     client = new TcpClient();
     try
     {
         client.Connect(settings.host, settings.port);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }