From a8fe9496d9d98a56010154b2452dea5adb7da4db Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jul 2018 21:37:27 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1bb7f519..9dac4fad 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -539,6 +539,66 @@ namespace WebSocketSharp.Server _websocket.Close (code, reason); } + /// + /// Closes the WebSocket connection for a session with the specified + /// code and reason. + /// + /// + /// 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. + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is + /// and there is + /// . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + protected void Close (CloseStatusCode code, string reason) + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.Close (code, reason); + } + /// /// Calls the method with the specified message. ///