public async Task <bool> TryLogin(Client client) { Login.CurrentInstance.Errormessage.Text = ""; try { if (LocalServiceClient == null) { LocalServiceClient = new SwnServiceClient(new InstanceContext(this), "netTcpBinding", "net.tcp://" + SettingHandler.GetIpPort() + "/SwnService"); } if (LocalServiceClient.State != CommunicationState.Opened) { LocalServiceClient.Open(); } var successfulLogin = await LocalServiceClient.ConnectAsync(client); return(successfulLogin); } catch (FaultException exception) { Login.CurrentInstance.Errormessage.Text = "Got " + exception.GetType(); CloseOrAbortServiceChannel(LocalServiceClient); return(false); } catch (CommunicationException) { Login.CurrentInstance.Errormessage.Text = "Server not Responding"; CloseOrAbortServiceChannel(LocalServiceClient); return(false); } catch (TimeoutException exception) { Login.CurrentInstance.Errormessage.Text = "Got " + exception.GetType(); CloseOrAbortServiceChannel(LocalServiceClient); return(false); } catch (Exception t) { MessageBox.Show(t.ToString()); CloseOrAbortServiceChannel(LocalServiceClient); return(false); } }
public async Task<bool> TryLogin( Client client ) { Login.CurrentInstance.Errormessage.Text = ""; try { if (LocalServiceClient == null) { LocalServiceClient = new SwnServiceClient(new InstanceContext(this), "netTcpBinding", "net.tcp://" + SettingHandler.GetIpPort() + "/SwnService"); } if (LocalServiceClient.State != CommunicationState.Opened) { LocalServiceClient.Open(); } var successfulLogin = await LocalServiceClient.ConnectAsync(client); return successfulLogin; } catch (FaultException exception) { Login.CurrentInstance.Errormessage.Text = "Got " + exception.GetType(); CloseOrAbortServiceChannel(LocalServiceClient); return false; } catch (CommunicationException) { Login.CurrentInstance.Errormessage.Text = "Server not Responding"; CloseOrAbortServiceChannel(LocalServiceClient); return false; } catch (TimeoutException exception) { Login.CurrentInstance.Errormessage.Text = "Got " + exception.GetType(); CloseOrAbortServiceChannel(LocalServiceClient); return false; } catch (Exception t) { MessageBox.Show(t.ToString()); CloseOrAbortServiceChannel(LocalServiceClient); return false; } }