[Modify] Throw exceptions

This commit is contained in:
sta 2016-11-16 16:01:22 +09:00
parent 09e803ffd7
commit 00348958cf

View File

@ -2664,14 +2664,12 @@ namespace WebSocketSharp
/// </param>
public void Send (byte[] data)
{
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
CheckSendParameter (data);
if (data == null)
throw new ArgumentNullException ("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);
}
send (Opcode.Binary, new MemoryStream (data));