/// <summary> /// Instructs the client proxy to close its connection from the server side, no additional messages will be sent to it. /// </summary> /// <param name="reason">The status reason why the connection is being closed. This may be /// sent to the client depending on implementation.</param> /// <param name="message">A human readonable description as to why the connection was closed by /// the server.</param> /// <param name="cancelToken">A cancellation token.</param> /// <returns>Task.</returns> public Task CloseConnection( ClientConnectionCloseStatus reason, string message = null, CancellationToken cancelToken = default) { this.ProcessCloseRequest(); if (_connection.State == ClientConnectionState.Open) { return(_connection.CloseAsync(reason, message, cancelToken)); } return(Task.CompletedTask); }