From ae3e92744e16d41f0bb27291ce17f143f2001ee1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Jul 2018 20:12:10 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 64 +++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2f7b9b07..a4664573 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -695,6 +695,70 @@ namespace WebSocketSharp.Server _websocket.CloseAsync (code, reason); } + /// + /// Closes the WebSocket connection for a session asynchronously with + /// the specified code and reason. + /// + /// + /// + /// This method does not wait for the close to be complete. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// + /// + /// + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// + /// + /// + /// The session has not started yet. + /// + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is + /// and there is reason. + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The size of is greater than 123 bytes. + /// + 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); + } + /// /// Calls the method with the specified message. ///