Microsoft.AspNetCore.SignalR.Hubs.HubPipelineModule.BuildDisconnect C# (CSharp) Méthode

BuildDisconnect() public méthode

Wraps a function that is called when a client disconnects from the HubDispatcher for each IHub the client was connected to. By default, this results in the IHub's OnDisconnected method being invoked.
public BuildDisconnect ( Func disconnect ) : Func
disconnect Func /// A task-returning function to be called when a client disconnects from a hub. /// This function takes two parameters: /// 1. The is being disconnected from. /// 2. A boolean, stopCalled, that is true if stop was called on the client and false if the client timed out. /// Timeouts can be caused by clients reconnecting to another SignalR server in scaleout. ///
Résultat Func
        public virtual Func<IHub, bool, Task> BuildDisconnect(Func<IHub, bool, Task> disconnect)
        {
            return (hub, stopCalled) =>
            {
                if (OnBeforeDisconnect(hub, stopCalled))
                {
                    return disconnect(hub, stopCalled).OrEmpty().Then((h, s) => OnAfterDisconnect(h, s), hub, stopCalled);
                }

                return TaskAsyncHelper.Empty;
            };
        }