Exemple #1
0
        public SubscribeResponse Subscribe(string resourceUri, IEnumerable <Selector> selectors, SubscribeRequest request)
        {
            EndpointAddressBuilder susbcriptionManagerEndpointAddress = new EndpointAddressBuilder();

            Expires expiration = request.Expires ?? Expires.FromTimeSpan(DefaultExpirationTime);

            Subsciption subsciption = GetManager(resourceUri, request.Filter).Subscribe(
                request.Filter,
                selectors,
                expiration,
                susbcriptionManagerEndpointAddress);

            lock (_activeSubscriptions)
            {
                _activeSubscriptions[subsciption.Identifier] = subsciption;
            }
            //R7.2.4-1
            return(new SubscribeResponse
            {
                SubscriptionManager = new SubscriptionManager(susbcriptionManagerEndpointAddress, subsciption.Identifier, OperationContextProxy.Current.LocalAddress, subsciption.DeliveryResourceUri),
                EnumerationContext = request.Delivery.Mode == Delivery.DeliveryModePull
                         ? new EnumerationContextKey(subsciption.Identifier)
                         : null,
                Expires = expiration
            });
        }
        public void Unsubscribe(Subsciption subsciption)
        {
            PullSubscription pullSubscription = (PullSubscription)subsciption;

            _handler.Unbind(pullSubscription);
            _deliveryServer.RemoveSubscription(pullSubscription);
            _subscriptions.Remove(subsciption.Identifier);
            subsciption.Dispose();
        }