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 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; } }
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 }); }
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, }); }
private Expires CalculateExpiration(Expires nullableExpirationValue) { return(nullableExpirationValue ?? Expires.FromTimeSpan(DefaultExpirationTime)); }