[Modify] Throw exceptions

This commit is contained in:
sta 2016-11-21 18:01:22 +09:00
parent c1ea361e2e
commit 922cd7e3b4

View File

@ -2773,16 +2773,14 @@ namespace WebSocketSharp
/// </param>
public void SendAsync (byte[] data, Action<bool> 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);
}