[Modify] Throw exception

This commit is contained in:
sta 2017-08-16 11:46:12 +09:00
parent 26525b12f3
commit fcc27fd4e2

View File

@ -1216,10 +1216,16 @@ namespace WebSocketSharp.Server
/// the send is complete. A <see cref="bool"/> passed to this delegate is <c>true</c> /// the send is complete. A <see cref="bool"/> passed to this delegate is <c>true</c>
/// if the send is complete successfully. /// if the send is complete successfully.
/// </param> /// </param>
public void SendToAsync (Stream stream, int length, string id, Action<bool> completed) public void SendToAsync (
Stream stream, int length, string id, Action<bool> completed
)
{ {
IWebSocketSession session; IWebSocketSession session;
if (TryGetSession (id, out session)) if (!TryGetSession (id, out session)) {
var msg = "The session could not be found.";
throw new ArgumentException (msg, "id");
}
session.Context.WebSocket.SendAsync (stream, length, completed); session.Context.WebSocket.SendAsync (stream, length, completed);
} }