From 922cd7e3b4c32d4f2aca03845067684a993b2554 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2016 18:01:22 +0900 Subject: [PATCH] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d10c4c3c..e1d975f7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2773,16 +2773,14 @@ namespace WebSocketSharp /// public void SendAsync (byte[] data, Action completed) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); - - return; + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + sendAsync (Opcode.Binary, new MemoryStream (data), completed); }