Пример #1
0
 public void JoinExitAuction(object sender, EventArgs evt)
 {
     //when client attempts to dis/connect to server
     view = (ClientView)(((Button)sender).FindForm());
     if (!connected)
     {
         //if not already connected attempt connection
         //get supplied IP Address and Port number from view
         string tempServerIP = view.getServerIP(), tempPort = view.getServerPortNumber();
         if (tempServerIP != "" && tempPort != "")
         {
             try
             {
                 //if not null attempt to parse
                 this.serverIP = IPAddress.Parse(tempServerIP);
                 this.portNumber = Int16.Parse(tempPort);
                 this.connectToServer();
             }
             catch (FormatException fe)
             {
                 //if parse fails tell user
                 MessageBox.Show("Please enter correct text for all fields.");
                 return;
             }
         }
         else
         {
             //tell user to add data to all fiels
             MessageBox.Show("Please enter text for all fields.");
             return;
         }
     }
     else if (connected)
     {
         //or if already connected discconect from server
         this.disconnectFromServer();
     }
 }