[Modify] Throw exceptions

master
sta 9 years ago
parent 7e98434f6c
commit c13dbeb051

@ -2722,17 +2722,19 @@ namespace WebSocketSharp
/// </param>
public void Send (string data)
{
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
CheckSendParameter (data);
if (_readyState != WebSocketState.Open) {
var msg = "The current state of the connection is not Open.";
throw new InvalidOperationException (msg);
}
if (msg != null) {
_logger.Error (msg);
error ("An error has occurred in sending data.", null);
if (data == null)
throw new ArgumentNullException ("data");
return;
}
byte[] bytes;
if (!data.TryGetUTF8EncodedBytes (out bytes))
throw new ArgumentException ("Cannot be UTF8 encoded.", "data");
send (Opcode.Text, new MemoryStream (data.UTF8Encode ()));
send (Opcode.Text, new MemoryStream (bytes));
}
/// <summary>

Loading…
Cancel
Save