[Modify] Throw exceptions
This commit is contained in:
parent
d13d4c8c79
commit
4cc4837fbe
@ -2848,17 +2848,19 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void SendAsync (string data, Action<bool> completed)
|
public void SendAsync (string data, Action<bool> completed)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
if (_readyState != WebSocketState.Open) {
|
||||||
CheckSendParameter (data);
|
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);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendAsync (Opcode.Text, new MemoryStream (data.UTF8Encode ()), completed);
|
if (data == null)
|
||||||
|
throw new ArgumentNullException ("data");
|
||||||
|
|
||||||
|
byte[] bytes;
|
||||||
|
if (!data.TryGetUTF8EncodedBytes (out bytes))
|
||||||
|
throw new ArgumentException ("Cannot be UTF8 encoded.", "data");
|
||||||
|
|
||||||
|
sendAsync (Opcode.Text, new MemoryStream (bytes), completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user