private void btnSubscribe_Click(object sender, EventArgs e)
        {
            try
            {
                EventsReceiver listener = new EventsReceiver();
                listener.NotificationReceived += listener_NotificationReceived;
                listener.Name = tbEventsReceiver.Text;
                _listener     = listener;

                _host = new ServiceHost(listener, new Uri(tbEventsReceiver.Text));
                ServiceEndpoint endpoint = _host.AddServiceEndpoint(typeof(Proxies.Events.NotificationConsumer), new WSHttpBinding(SecurityMode.None), string.Empty);
                _host.Open();


                Subscribe request = new Subscribe();
                request.ConsumerReference               = new EndpointReferenceType();
                request.ConsumerReference.Address       = new AttributedURIType();
                request.ConsumerReference.Address.Value = tbEventsReceiver.Text;

                if (!string.IsNullOrEmpty(tbTopicsFilter.Text))
                {
                    request.Filter = CreateFilter();
                }

                request.InitialTerminationTime = tbSubscriptionTime.Text;

                SubscribeResponse response = Client.Subscribe(request);
                tcSubscription.SelectedTab   = tpManageSubscription;
                _subscriptionReference       = response.SubscriptionReference;
                tbSubscriptionReference.Text = _subscriptionReference.Address.Value;
                _subscribed = true;
                if (response.TerminationTime.HasValue)
                {
                    _terminationTime       = response.TerminationTime.Value;
                    tbTerminationTime.Text = _terminationTime.ToString("hh:mm:ss.fff");

                    DisplayTimeLeft();
                }

                EndpointAddress            addr      = new EndpointAddress(_subscriptionReference.Address.Value);
                EndpointReferenceBehaviour behaviour = new EndpointReferenceBehaviour(response.SubscriptionReference);

                _subscriptionManager = new SubscriptionManagerClient(_custombindingSoap12, addr);
                _subscriptionManager.Endpoint.Behaviors.Add(behaviour);

                _pullPointSubscriptionClient = new PullPointSubscriptionClient(_custombindingSoap12, addr);
                _pullPointSubscriptionClient.Endpoint.Behaviors.Add(behaviour);

                timer.Start();
                btnSubscribe.Enabled               = false;
                btnRenew.Enabled                   = true;
                btnUnsubscribe.Enabled             = true;
                btnSetSynchronizationPoint.Enabled = true;
            }
            catch (Exception exc)
            {
                _host.Close();
                MessageBox.Show(exc.Message);
            }
        }
Example #2
0
 protected void AttachAddressing(ServiceEndpoint endpoint,
                                 Proxies.Event.EndpointReferenceType endpointReference)
 {
     if (endpointReference.ReferenceParameters != null && endpointReference.ReferenceParameters.Any != null)
     {
         EndpointReferenceBehaviour behaviour = new EndpointReferenceBehaviour(endpointReference);
         endpoint.Behaviors.Add(behaviour);
     }
 }
Example #3
0
 protected void AttachAddressing(System.ServiceModel.Description.ServiceEndpoint endpoint,
                                 TestTool.Proxies.Event.EndpointReferenceType endpointReference)
 {
     if (endpointReference.ReferenceParameters != null && endpointReference.ReferenceParameters.Any != null)
     {
         Utils.EndpointReferenceBehaviour behaviour = new EndpointReferenceBehaviour(endpointReference);
         endpoint.Behaviors.Add(behaviour);
     }
 }