private async void OnClose(object sender, RoutedEventArgs e) { DoWait(false); if (client != null) { await client.CloseAsync(); } client = null; }
/// <summary> /// Used when there's a URI to send seperate from the normal UI. /// </summary> /// <param name="uri"></param> /// <returns></returns> public async Task DoSendUri(Uri uri) { try { DoWait(true); // finger://[email protected]//W // OR finger://example.com/user // OR finger://example.com//W%20user var request = ParsedFingerCommand.ParseFromUri(uri); if (request == null) { Client_LogEvent(this, $"ERROR: Client: can't parse finger {uri}. Should be finger://[email protected] (for example)"); } else { // Update UI from the URI via the request uiAddress.Text = request.OriginalCommand; uiService.Text = request.SendToPort; uiWSwitch.IsOn = request.HasWSwitch; if (client == null) { client = new FingerClient_Rfc_1288(); client.LogEvent += Client_LogEvent; } await client.WriteAsync(request); } } catch (Exception ex) { Client_LogEvent(this, $"ERROR: Client: Send exception {ex.Message} for host {uri.Host}"); } DoWait(false); }
private async void OnSend(object sender, RoutedEventArgs e) { try { DoWait(true); // Might be [email protected] // OR just @example.com OR example.com // OR finger://[email protected]//W // OR finger://example.com/user ParsedFingerCommand request = ParsedFingerCommand.ParseFromUxString(uiAddress.Text.Trim(), uiService.Text, uiWSwitch.IsOn); if (request == null) { Client_LogEvent(this, $"ERROR: Client: can't parse finger {uiAddress.Text}. Should be [email protected] (for example)"); } else { uiService.Text = request.SendToPort; uiWSwitch.IsOn = request.HasWSwitch; if (client == null) { client = new FingerClient_Rfc_1288(); client.LogEvent += Client_LogEvent; } await client.WriteAsync(request); } } catch (Exception ex) { Client_LogEvent(this, $"ERROR: Client: Send exception {ex.Message} for host {uiAddress.Text}"); } DoWait(false); }