From f8955042f717a5c942deb7e612b7b62129347be1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Feb 2016 16:19:09 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/WebSocket.cs | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b84acd7..ea1a19b3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -810,6 +810,51 @@ namespace WebSocketSharp return true; } + private bool checkIfAvailable ( + bool client, + bool server, + bool connecting, + bool open, + bool closing, + bool closed, + out string message + ) + { + message = null; + + if (!client && _client) { + message = "This operation isn't available in: client"; + return false; + } + + if (!server && !_client) { + message = "This operation isn't available in: server"; + return false; + } + + if (!connecting && _readyState == WebSocketState.Connecting) { + message = "This operation isn't available in: connecting"; + return false; + } + + if (!open && _readyState == WebSocketState.Open) { + message = "This operation isn't available in: open"; + return false; + } + + if (!closing && _readyState == WebSocketState.Closing) { + message = "This operation isn't available in: closing"; + return false; + } + + if (!closed && _readyState == WebSocketState.Closed) { + message = "This operation isn't available in: closed"; + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null;