示例#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
            });
        }
示例#2
0
 public void Renew(Expires expires)
 {
     if (expires.Value is DateTime)
     {
         _expirationDate = (DateTime)expires.Value;
     }
     else
     {
         if (expires.Value == null)
         {
             expires = Expires.FromTimeSpan(new TimeSpan(1, 0, 0));
         }
         _expirationDate = DateTime.Now + (TimeSpan)expires.Value;
     }
 }
示例#3
0
        public RenewResponse Renew(RenewRequest request)
        {
            IdentifierHeader identifierHeader = OperationContextProxy.Current.FindHeader <IdentifierHeader>();

            lock (_activeSubscriptions)
            {
                Subsciption toRenew;
                if (_activeSubscriptions.TryGetValue(identifierHeader.Value, out toRenew))
                {
                    toRenew.Renew(request.Expires ?? Expires.FromTimeSpan(DefaultExpirationTime));
                }
            }
            return(new RenewResponse
            {
                Expires = request.Expires
            });
        }
示例#4
0
        public void If_pull_returns_no_items_exception_is_thrown()
        {
            IEventingRequestHandler <int> mockHandler = MockRepository.GenerateMock <IEventingRequestHandler <int> >();

            OperationContextProxy.Dummy.LocalAddress = ResourceUri;

            EventingServer server = new EventingServer();

            server.BindWithPullDelivery(ResourceUri, FilterMap.DefaultDialect, typeof(void), mockHandler, ResourceUri);
            SubscribeResponse subscribeResponse = server.Subscribe(ResourceUri.ToString(), null, new SubscribeRequest
            {
                Delivery = Delivery.Pull(),
                Expires  = Expires.FromTimeSpan(TimeSpan.Zero)
            });

            server.Pull(new PullRequest
            {
                EnumerationContext = subscribeResponse.EnumerationContext,
            });
        }
示例#5
0
 private Expires CalculateExpiration(Expires nullableExpirationValue)
 {
     return(nullableExpirationValue ?? Expires.FromTimeSpan(DefaultExpirationTime));
 }