|
|
|
@ -103,10 +103,10 @@ namespace WebSocketSharp.Server
|
|
|
|
/// </para>
|
|
|
|
/// </para>
|
|
|
|
/// </remarks>
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="port">
|
|
|
|
/// <param name="port">
|
|
|
|
/// An <see cref="int"/> that represents the port number to listen.
|
|
|
|
/// An <see cref="int"/> that represents the port number on which to listen.
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <paramref name="port"/> is not between 1 and 65535.
|
|
|
|
/// <paramref name="port"/> isn't between 1 and 65535.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
public WebSocketServer (int port)
|
|
|
|
public WebSocketServer (int port)
|
|
|
|
: this (System.Net.IPAddress.Any, port)
|
|
|
|
: this (System.Net.IPAddress.Any, port)
|
|
|
|
@ -118,8 +118,15 @@ namespace WebSocketSharp.Server
|
|
|
|
/// with the specified WebSocket URL.
|
|
|
|
/// with the specified WebSocket URL.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// <remarks>
|
|
|
|
/// An instance initialized by this constructor listens for the incoming
|
|
|
|
/// <para>
|
|
|
|
/// connection requests on the port number of <paramref name="url"/>.
|
|
|
|
/// An instance initialized by this constructor listens for the incoming
|
|
|
|
|
|
|
|
/// connection requests on the port (if any) in <paramref name="url"/>.
|
|
|
|
|
|
|
|
/// </para>
|
|
|
|
|
|
|
|
/// <para>
|
|
|
|
|
|
|
|
/// So if <paramref name="url"/> is without a port, either port 80 or 443
|
|
|
|
|
|
|
|
/// is used on which to listen. It's determined by the scheme (ws or wss)
|
|
|
|
|
|
|
|
/// in <paramref name="url"/>. (port 80 if the scheme is ws.)
|
|
|
|
|
|
|
|
/// </para>
|
|
|
|
/// </remarks>
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="url">
|
|
|
|
/// <param name="url">
|
|
|
|
/// A <see cref="string"/> that represents the WebSocket URL of the server.
|
|
|
|
/// A <see cref="string"/> that represents the WebSocket URL of the server.
|
|
|
|
@ -161,14 +168,14 @@ namespace WebSocketSharp.Server
|
|
|
|
/// connection requests on <paramref name="port"/>.
|
|
|
|
/// connection requests on <paramref name="port"/>.
|
|
|
|
/// </remarks>
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="port">
|
|
|
|
/// <param name="port">
|
|
|
|
/// An <see cref="int"/> that represents the port number to listen.
|
|
|
|
/// An <see cref="int"/> that represents the port number on which to listen.
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <param name="secure">
|
|
|
|
/// <param name="secure">
|
|
|
|
/// A <see cref="bool"/> that indicates providing a secure connection or not.
|
|
|
|
/// A <see cref="bool"/> that indicates providing a secure connection or not.
|
|
|
|
/// (<c>true</c> indicates providing a secure connection.)
|
|
|
|
/// (<c>true</c> indicates providing a secure connection.)
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <paramref name="port"/> is not between 1 and 65535.
|
|
|
|
/// <paramref name="port"/> isn't between 1 and 65535.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
/// <exception cref="ArgumentException">
|
|
|
|
/// <exception cref="ArgumentException">
|
|
|
|
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
|
|
|
|
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
|
|
|
|
@ -193,19 +200,20 @@ namespace WebSocketSharp.Server
|
|
|
|
/// </para>
|
|
|
|
/// </para>
|
|
|
|
/// </remarks>
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="address">
|
|
|
|
/// <param name="address">
|
|
|
|
/// A <see cref="System.Net.IPAddress"/> that represents the local IP address.
|
|
|
|
/// A <see cref="System.Net.IPAddress"/> that represents the local IP address
|
|
|
|
|
|
|
|
/// of the server.
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <param name="port">
|
|
|
|
/// <param name="port">
|
|
|
|
/// An <see cref="int"/> that represents the port number to listen.
|
|
|
|
/// An <see cref="int"/> that represents the port number on which to listen.
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <exception cref="ArgumentNullException">
|
|
|
|
/// <exception cref="ArgumentNullException">
|
|
|
|
/// <paramref name="address"/> is <see langword="null"/>.
|
|
|
|
/// <paramref name="address"/> is <see langword="null"/>.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <paramref name="port"/> is not between 1 and 65535.
|
|
|
|
/// <paramref name="port"/> isn't between 1 and 65535.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
/// <exception cref="ArgumentException">
|
|
|
|
/// <exception cref="ArgumentException">
|
|
|
|
/// <paramref name="address"/> is not the local IP address.
|
|
|
|
/// <paramref name="address"/> isn't a local IP address.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
public WebSocketServer (System.Net.IPAddress address, int port)
|
|
|
|
public WebSocketServer (System.Net.IPAddress address, int port)
|
|
|
|
: this (address, port, port == 443 ? true : false)
|
|
|
|
: this (address, port, port == 443 ? true : false)
|
|
|
|
@ -222,10 +230,11 @@ namespace WebSocketSharp.Server
|
|
|
|
/// connection requests on <paramref name="port"/>.
|
|
|
|
/// connection requests on <paramref name="port"/>.
|
|
|
|
/// </remarks>
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="address">
|
|
|
|
/// <param name="address">
|
|
|
|
/// A <see cref="System.Net.IPAddress"/> that represents the local IP address.
|
|
|
|
/// A <see cref="System.Net.IPAddress"/> that represents the local IP address
|
|
|
|
|
|
|
|
/// of the server.
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <param name="port">
|
|
|
|
/// <param name="port">
|
|
|
|
/// An <see cref="int"/> that represents the port number to listen.
|
|
|
|
/// An <see cref="int"/> that represents the port number on which to listen.
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <param name="secure">
|
|
|
|
/// <param name="secure">
|
|
|
|
/// A <see cref="bool"/> that indicates providing a secure connection or not.
|
|
|
|
/// A <see cref="bool"/> that indicates providing a secure connection or not.
|
|
|
|
@ -235,11 +244,11 @@ namespace WebSocketSharp.Server
|
|
|
|
/// <paramref name="address"/> is <see langword="null"/>.
|
|
|
|
/// <paramref name="address"/> is <see langword="null"/>.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">
|
|
|
|
/// <paramref name="port"/> is not between 1 and 65535.
|
|
|
|
/// <paramref name="port"/> isn't between 1 and 65535.
|
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
/// <exception cref="ArgumentException">
|
|
|
|
/// <exception cref="ArgumentException">
|
|
|
|
/// <para>
|
|
|
|
/// <para>
|
|
|
|
/// <paramref name="address"/> is not the local IP address.
|
|
|
|
/// <paramref name="address"/> isn't a local IP address.
|
|
|
|
/// </para>
|
|
|
|
/// </para>
|
|
|
|
/// <para>
|
|
|
|
/// <para>
|
|
|
|
/// -or-
|
|
|
|
/// -or-
|
|
|
|
@ -332,10 +341,10 @@ namespace WebSocketSharp.Server
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a value indicating whether the server has been started.
|
|
|
|
/// Gets a value indicating whether the server has started.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>
|
|
|
|
/// <value>
|
|
|
|
/// <c>true</c> if the server has been started; otherwise, <c>false</c>.
|
|
|
|
/// <c>true</c> if the server has started; otherwise, <c>false</c>.
|
|
|
|
/// </value>
|
|
|
|
/// </value>
|
|
|
|
public bool IsListening {
|
|
|
|
public bool IsListening {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
@ -344,10 +353,10 @@ namespace WebSocketSharp.Server
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a value indicating whether the server provides secure connection.
|
|
|
|
/// Gets a value indicating whether the server provides a secure connection.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>
|
|
|
|
/// <value>
|
|
|
|
/// <c>true</c> if the server provides secure connection; otherwise,
|
|
|
|
/// <c>true</c> if the server provides a secure connection; otherwise,
|
|
|
|
/// <c>false</c>.
|
|
|
|
/// <c>false</c>.
|
|
|
|
/// </value>
|
|
|
|
/// </value>
|
|
|
|
public bool IsSecure {
|
|
|
|
public bool IsSecure {
|
|
|
|
@ -395,7 +404,7 @@ namespace WebSocketSharp.Server
|
|
|
|
/// Gets the port on which to listen for incoming connection requests.
|
|
|
|
/// Gets the port on which to listen for incoming connection requests.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>
|
|
|
|
/// <value>
|
|
|
|
/// An <see cref="int"/> that represents the port number to listen.
|
|
|
|
/// An <see cref="int"/> that represents the port number on which to listen.
|
|
|
|
/// </value>
|
|
|
|
/// </value>
|
|
|
|
public int Port {
|
|
|
|
public int Port {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
@ -622,10 +631,10 @@ namespace WebSocketSharp.Server
|
|
|
|
_receiveRequestThread.Start ();
|
|
|
|
_receiveRequestThread.Start ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void stopListener (int timeOut)
|
|
|
|
private void stopListener (int millisecondsTimeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_listener.Stop ();
|
|
|
|
_listener.Stop ();
|
|
|
|
_receiveRequestThread.Join (timeOut);
|
|
|
|
_receiveRequestThread.Join (millisecondsTimeout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static bool tryCreateUri (string uriString, out Uri result, out string message)
|
|
|
|
private static bool tryCreateUri (string uriString, out Uri result, out string message)
|
|
|
|
|