[Modify] Throw exceptions

master
sta 9 years ago
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) { if (file == null)
_logger.Error (msg); throw new ArgumentNullException ("file");
error ("An error has occurred in sending data.", null);
return; FileStream stream;
} if (!file.TryOpenRead (out stream))
throw new ArgumentException ("Cannot be opened to read.", "file");
sendAsync (Opcode.Binary, file.OpenRead (), completed); sendAsync (Opcode.Binary, stream, completed);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save