[Modify] Throw exceptions
This commit is contained in:
parent
2fd8928eb9
commit
e4542bee97
@ -2808,17 +2808,19 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void SendAsync (FileInfo file, Action<bool> completed)
|
public void SendAsync (FileInfo file, Action<bool> completed)
|
||||||
{
|
{
|
||||||
var msg = _readyState.CheckIfAvailable (false, true, false, false) ??
|
if (_readyState != WebSocketState.Open) {
|
||||||
CheckSendParameter (file);
|
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.Binary, file.OpenRead (), completed);
|
if (file == null)
|
||||||
|
throw new ArgumentNullException ("file");
|
||||||
|
|
||||||
|
FileStream stream;
|
||||||
|
if (!file.TryOpenRead (out stream))
|
||||||
|
throw new ArgumentException ("Cannot be opened to read.", "file");
|
||||||
|
|
||||||
|
sendAsync (Opcode.Binary, stream, completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user