internal Subscription(long id, string database, SubscriptionConnectionOptions options, IAsyncDatabaseCommands commands, IDatabaseChanges changes, DocumentConvention conventions, bool open, Func <Task> ensureOpenSubscription) { this.id = id; this.options = options; this.commands = commands; this.changes = changes; this.conventions = conventions; this.ensureOpenSubscription = ensureOpenSubscription; SubscriptionLifetimeTask = taskCompletionSource.Task; if (typeof(T) != typeof(RavenJObject)) { isStronglyTyped = true; generateEntityIdOnTheClient = new GenerateEntityIdOnTheClient(conventions, entity => AsyncHelpers.RunSync(() => conventions.GenerateDocumentKeyAsync(database, commands, entity))); } if (open) { Start(); } else { if (options.Strategy != SubscriptionOpeningStrategy.WaitForFree) { throw new InvalidOperationException("Subscription isn't open while its opening strategy is: " + options.Strategy); } } if (options.Strategy == SubscriptionOpeningStrategy.WaitForFree) { WaitForSubscriptionReleased(); } }
internal Subscription(long id, string database, SubscriptionConnectionOptions options, IAsyncDatabaseCommands commands, IDatabaseChanges changes, DocumentConvention conventions, Func <Task> ensureOpenSubscription) { this.id = id; this.options = options; this.commands = commands; this.changes = changes; this.conventions = conventions; this.ensureOpenSubscription = ensureOpenSubscription; if (typeof(T) != typeof(RavenJObject)) { isStronglyTyped = true; generateEntityIdOnTheClient = new GenerateEntityIdOnTheClient(conventions, entity => conventions.GenerateDocumentKeyAsync(database, commands, entity).ResultUnwrap()); } StartWatchingDocs(); StartPullingTask = StartPullingDocs(); }