Task <IListener> ITriggerBinding.CreateListenerAsync(ListenerFactoryContext context) { DaprListenerBase daprListener = this.OnCreateListener(context.Executor); this.serviceListener.AddFunctionListener(daprListener); return(Task.FromResult <IListener>(daprListener)); }
internal void AddFunctionListener(DaprListenerBase daprListener) { if (this.serverStarted > 0) { throw new InvalidOperationException("Cannot add listeners after the host has been started."); } this.listeners.Add(daprListener); }
internal async Task DeregisterListenerAsync(DaprListenerBase listener, CancellationToken cancellationToken) { this.listeners.Remove(listener); if (this.host != null && this.listeners.Count == 0 && Interlocked.CompareExchange(ref this.serverStarted, 0, 1) == 1) { this.log.LogInformation($"Stopping Dapr HTTP listener."); await this.host.StopAsync(cancellationToken); this.log.LogInformation($"Dapr HTTP host stopped successfully."); } }