Example #1
0
        private void Connect_button_Click(object sender, RoutedEventArgs e)
        {
            listMessage.Items.Clear();
            try
            {
                s = new SocketCl();
                s.InitSocket();
                int success = s.Connect(session.ConnectorIP, session.ConnectorPort);
                if (success == 1)
                {
                    Username.IsReadOnly      = true;
                    Username.IsEnabled       = false;
                    Listen_button.IsEnabled  = false;
                    Connect_button.IsEnabled = false;
                }
            }

            catch (ArgumentNullException ae)
            {
                MessageBox.Show(ae.ToString());
            }
            catch (SocketException se)
            {
                MessageBox.Show("No user on the specified IP/Port.");
            }
        }
Example #2
0
 private void Listen_button_Click(object sender, RoutedEventArgs e)
 {
     listMessage.Items.Clear();
     try
     {
         s = new SocketCl();
         s.InitSocket();
         int success = s.Listen(session.ListenerPort);
         if (success == 1)
         {
             Username.IsReadOnly      = true;
             Username.IsEnabled       = false;
             Listen_button.IsEnabled  = false;
             Connect_button.IsEnabled = false;
         }
     }
     catch (SocketException se)
     {
         MessageBox.Show("Connection broken.");
         Listen_button.IsEnabled = true;
     }
 }