/// <summary> /// sends request to log in to host /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, RoutedEventArgs e) { if (AllboxesFilled()) { try { ClientCallback callback = new ClientCallback(); var instanceCallback = new InstanceContext(callback); FIARServiceClient client = new FIARServiceClient(instanceCallback); string username = tbUserName.Text.Trim(); string pass = tbPass.Password.ToString(); client.PlayerLogin(username, pass); WaitingRoom waitingRoom = new WaitingRoom(client, username, callback); this.Close(); waitingRoom.Show(); } catch (FaultException <PlayerAlreadyConnectedFault> ex) { MessageBox.Show(ex.Detail.Details); } catch (FaultException <PlayerDoesntExistInDataBase> ex) { MessageBox.Show(ex.Detail.Details); } catch (Exception) { MessageBox.Show("Server is not avalibale"); } } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { try { if (!gameEnded) { Client.Disconnected(UserName); } waitingRoom.Show(); waitingRoom.UpdatePlayersAvailable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }