[Modify] Polish it
This commit is contained in:
parent
e8d2eab0cf
commit
6043ce7325
@ -2693,37 +2693,37 @@ namespace WebSocketSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the specified <paramref name="file"/> as the binary data using
|
/// Sends the specified <paramref name="fileInfo"/> as the binary data using
|
||||||
/// the WebSocket connection.
|
/// the WebSocket connection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file">
|
/// <param name="fileInfo">
|
||||||
/// A <see cref="FileInfo"/> that represents the file to send.
|
/// A <see cref="FileInfo"/> that represents the file to send.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <exception cref="InvalidOperationException">
|
/// <exception cref="InvalidOperationException">
|
||||||
/// The current state of the connection is not Open.
|
/// The current state of the connection is not Open.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
/// <exception cref="ArgumentNullException">
|
/// <exception cref="ArgumentNullException">
|
||||||
/// <paramref name="file"/> is <see langword="null"/>.
|
/// <paramref name="fileInfo"/> is <see langword="null"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// <paramref name="file"/> cannot be opened to read.
|
/// <paramref name="fileInfo"/> cannot be opened to read.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void Send (FileInfo file)
|
public void Send (FileInfo fileInfo)
|
||||||
{
|
{
|
||||||
if (_readyState != WebSocketState.Open) {
|
if (_readyState != WebSocketState.Open) {
|
||||||
var msg = "The current state of the connection is not Open.";
|
var msg = "The current state of the connection is not Open.";
|
||||||
throw new InvalidOperationException (msg);
|
throw new InvalidOperationException (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file == null)
|
if (fileInfo == null)
|
||||||
throw new ArgumentNullException ("file");
|
throw new ArgumentNullException ("fileInfo");
|
||||||
|
|
||||||
if (!file.Exists)
|
if (!fileInfo.Exists)
|
||||||
throw new ArgumentException ("The file does not exist.", "file");
|
throw new ArgumentException ("The file does not exist.", "fileInfo");
|
||||||
|
|
||||||
FileStream stream;
|
FileStream stream;
|
||||||
if (!file.TryOpenRead (out stream))
|
if (!fileInfo.TryOpenRead (out stream))
|
||||||
throw new ArgumentException ("Cannot be opened to read.", "file");
|
throw new ArgumentException ("The file could not be opened.", "fileInfo");
|
||||||
|
|
||||||
send (Opcode.Binary, stream);
|
send (Opcode.Binary, stream);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user