[Modify] Throw exceptions
This commit is contained in:
parent
a985eea230
commit
a002a77d1d
@ -2893,16 +2893,20 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void SendAsync (Stream stream, int length, Action<bool> completed)
|
public void SendAsync (Stream stream, int length, Action<bool> completed)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
if (_readyState != WebSocketState.Open) {
|
||||||
CheckSendParameters (stream, length);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stream == null)
|
||||||
|
throw new ArgumentNullException ("stream");
|
||||||
|
|
||||||
|
if (!stream.CanRead)
|
||||||
|
throw new ArgumentException ("Cannot be read.", "stream");
|
||||||
|
|
||||||
|
if (length < 1)
|
||||||
|
throw new ArgumentException ("Less than 1.", "length");
|
||||||
|
|
||||||
stream.ReadBytesAsync (
|
stream.ReadBytesAsync (
|
||||||
length,
|
length,
|
||||||
data => {
|
data => {
|
||||||
|
Loading…
Reference in New Issue
Block a user