[Modify] Add it
This commit is contained in:
parent
af335569fe
commit
ae3e92744e
@ -695,6 +695,70 @@ namespace WebSocketSharp.Server
|
||||
_websocket.CloseAsync (code, reason);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the WebSocket connection for a session asynchronously with
|
||||
/// the specified code and reason.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method does not wait for the close to be complete.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This method does nothing if the current state of the connection is
|
||||
/// Closing or Closed.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="code">
|
||||
/// <para>
|
||||
/// One of the <see cref="CloseStatusCode"/> enum values.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// It represents the status code indicating the reason for the close.
|
||||
/// </para>
|
||||
/// </param>
|
||||
/// <param name="reason">
|
||||
/// <para>
|
||||
/// A <see cref="string"/> that represents the reason for the close.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The size must be 123 bytes or less in UTF-8.
|
||||
/// </para>
|
||||
/// </param>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// The session has not started yet.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// <para>
|
||||
/// <paramref name="code"/> is
|
||||
/// <see cref="CloseStatusCode.MandatoryExtension"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// -or-
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <paramref name="code"/> is
|
||||
/// <see cref="CloseStatusCode.NoStatus"/> and there is reason.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// -or-
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <paramref name="reason"/> could not be UTF-8-encoded.
|
||||
/// </para>
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// The size of <paramref name="reason"/> is greater than 123 bytes.
|
||||
/// </exception>
|
||||
protected void CloseAsync (CloseStatusCode code, string reason)
|
||||
{
|
||||
if (_websocket == null) {
|
||||
var msg = "The session has not started yet.";
|
||||
throw new InvalidOperationException (msg);
|
||||
}
|
||||
|
||||
_websocket.CloseAsync (code, reason);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls the <see cref="OnError"/> method with the specified message.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user