private void disconnect_Click(object sender, RoutedEventArgs e) { disconnect.IsEnabled = false; approvalType.IsEnabled = false; docName.IsEnabled = false; document.IsEnabled = false; requestApproval.IsEnabled = false; SubscriptionServiceClient sclient = new SubscriptionServiceClient(); sclient.Endpoint.Address = subscriptionAddr; statusWriter.WriteLine("Unsubcribing from service ..."); try { sclient.Unsubscribe(user); } catch (Exception) { statusWriter.WriteLine("Unsubscribe failed ... forcing unsubcription"); } subscribed = false; statusWriter.WriteLine("Unsubscribed"); connect.IsEnabled = true; name.IsEnabled = true; userType.IsEnabled = true; }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { // Let the approval manager know that this client is no longer participating // in the approval system because the client app is closing if (subscribed) { SubscriptionServiceClient sclient = new SubscriptionServiceClient(); sclient.Endpoint.Address = subscriptionAddr; statusWriter.WriteLine("Unsubcribing from service ..."); try { sclient.Unsubscribe(user); statusWriter.WriteLine("Unsubscribed"); } catch (Exception) { statusWriter.WriteLine("Failed to unsubscribe from service ..."); } } wsh.Close(); sh.Close(); base.OnClosing(e); }
private void connect_Click(object sender, RoutedEventArgs e) { connect.IsEnabled = false; name.IsEnabled = false; userType.IsEnabled = false; SubscriptionServiceClient sclient = new SubscriptionServiceClient(); // Set endpoint to previously discovered address sclient.Endpoint.Address = subscriptionAddr; statusWriter.WriteLine("Subscribing to " + sclient.Endpoint.Address + " as " + name.Text + " of type " + userType.Text); user = sclient.Subscribe(new User(name.Text, userType.Text, addrListenForApprovalRequests, addrListenForApprovalResponses)); subscribed = true; disconnect.IsEnabled = true; approvalType.IsEnabled = true; docName.IsEnabled = true; document.IsEnabled = true; requestApproval.IsEnabled = true; statusWriter.WriteLine("Subscribed with user guid " + user.Id); }