public Lobby(ServiceClient client, ClientCallback callback, string username)
 {
     online = true;
     try
     {
         InitializeComponent();
         InviteB.Visibility = Visibility.Hidden;
         timer    = new DispatcherTimer();
         Client   = client;
         Username = username;
         Callback = callback;
         Client   = client;
         callback.ReceivedInvitation = ShowReceivedInvitation; //assign to delegate
         client.AddPlayerToLobby(username);                    //add the player to the wating list
         mainWindow         = null;
         ConnIndicator.Fill = System.Windows.Media.Brushes.Green;
         FillLBOnLine();//FillLBOnLine get from the server all the online and available players
     }
     catch (FaultException <InvitationFault> fault)
     {
         MessageBox.Show(fault.Detail.Details, Username);
     }
     catch (TimeoutException)
     {
         timer.Stop();
         ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
         online             = false;
         MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", Username + " connection unstable");
         this.Close();
     }
     catch (CommunicationObjectFaultedException)
     {
         timer.Stop();
         ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
         online             = false;
         MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable");
         this.Close();
     }
     catch (Exception ex)
     {
         timer.Stop();
         ConnIndicator.Fill = System.Windows.Media.Brushes.Red;
         online             = false;
         MessageBox.Show(ex.ToString(), Username + " connection unstable");
         this.Close();
     }
 }