The `e.Code` (`WebSocketSharp.CloseEventArgs.Code`, its type is `WebSocketSharp.Frame.CloseStatusCode`) contains the close status code
and the `e.Reason` (`WebSocketSharp.CloseEventArgs.Reason`, its type is `string`) contains the reason why closes, so you operate them.
The `e.Code` (`WebSocketSharp.CloseEventArgs.Code`, its type is `WebSocketSharp.Frame.CloseStatusCode`) contains the close status code and the `e.Reason` (`WebSocketSharp.CloseEventArgs.Reason`, its type is `string`) contains the reason why closes, so you operate them.
/// Initializes a new instance of the <see cref="WebSocketSharp.WebSocket"/> class with the specified WebSocket URL, OnOpen, OnMessage, OnError, OnClose event handlers and subprotocols.
/// </summary>
/// <param name='url'>
/// <param name="url">
/// A <see cref="string"/> that contains the WebSocket URL.
/// </param>
/// <param name='onOpen'>
/// <param name="onOpen">
/// An OnOpen event handler.
/// </param>
/// <param name='onMessage'>
/// <param name="onMessage">
/// An OnMessage event handler.
/// </param>
/// <param name='onError'>
/// <param name="onError">
/// An OnError event handler.
/// </param>
/// <param name='onClose'>
/// <param name="onClose">
/// An OnClose event handler.
/// </param>
/// <param name='protocols'>
/// <param name="protocols">
/// An array of <see cref="string"/> that contains the WebSocket subprotocols if any.
/// </param>
/// <exception cref='ArgumentException'>
/// <exception cref="ArgumentNullException">
/// <paramref name="url"/> is <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// <paramref name="url"/> is not valid WebSocket URL.
/// </exception>
publicWebSocket(
@ -687,6 +692,24 @@ namespace WebSocketSharp {
returntrue;
}
privateboolisValidUrl(stringurl,outstringmessage)
{
if(url==String.Empty)
{
message="'url' is empty.";
returnfalse;
}
varuri=url.ToUri();
if(!uri.IsValidWebSocketUri(outmessage))
returnfalse;
_uri=uri;
message=String.Empty;
returntrue;
}
privatevoidmessage()
{
try
@ -1082,7 +1105,7 @@ namespace WebSocketSharp {
#region Public Methods
/// <summary>
/// Sends a Close frame and closes the WebSocket connection and releases all associated resources.
/// Sends a Close frame using the connection and closes the connection and releases all associated resources.
/// </summary>
publicvoidClose()
{
@ -1090,9 +1113,9 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Close frame and closes the WebSocket connection and releases all associated resources.
/// Sends a Close frame using the connection and closes the connection and releases all associated resources.
/// </summary>
/// <param name='code'>
/// <param name="code">
/// A <see cref="WebSocketSharp.Frame.CloseStatusCode"/>.
/// </param>
publicvoidClose(CloseStatusCodecode)
@ -1101,12 +1124,12 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Close frame and closes the WebSocket connection and releases all associated resources.
/// Sends a Close frame using the connection and closes the connection and releases all associated resources.
/// </summary>
/// <param name='code'>
/// <param name="code">
/// A <see cref="WebSocketSharp.Frame.CloseStatusCode"/>.
/// </param>
/// <param name='reason'>
/// <param name="reason">
/// A <see cref="string"/> that contains the reason why closes.
/// </param>
publicvoidClose(CloseStatusCodecode,stringreason)
@ -1146,7 +1169,7 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Close frame and closes the WebSocket connection and releases all associated resources.
/// Sends a Close frame using the connection and closes the connection and releases all associated resources.
/// </summary>
/// <remarks>
/// Call <see cref="Dispose"/> when you are finished using the <see cref="WebSocketSharp.WebSocket"/>. The
@ -1160,7 +1183,7 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Ping frame.
/// Sends a Ping frame using the connection.
/// </summary>
/// <returns>
/// <c>true</c> if the WebSocket receives a Pong frame in a time; otherwise, <c>false</c>.
@ -1171,9 +1194,9 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Ping frame with a message.
/// Sends a Ping frame with a message using the connection.
/// </summary>
/// <param name='data'>
/// <param name="data">
/// A <see cref="string"/> that contains the message data to be sent.
/// </param>
/// <returns>
@ -1185,9 +1208,9 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Text data frame.
/// Sends a text data using the connection.
/// </summary>
/// <param name='data'>
/// <param name="data">
/// A <see cref="string"/> that contains the text data to be sent.
/// </param>
publicvoidSend(stringdata)
@ -1197,9 +1220,9 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Binary data frame.
/// Sends a binary data using the connection.
/// </summary>
/// <param name='data'>
/// <param name="data">
/// An array of <see cref="byte"/> that contains the binary data to be sent.
/// </param>
publicvoidSend(byte[]data)
@ -1208,9 +1231,9 @@ namespace WebSocketSharp {
}
/// <summary>
/// Sends a Binary data frame.
/// Sends a binary data using the connection.
/// </summary>
/// <param name='file'>
/// <param name="file">
/// A <see cref="FileInfo"/> that contains the binary data to be sent.