Fix due to the modified WsStream.cs
This commit is contained in:
@@ -67,8 +67,18 @@ namespace WebSocketSharp.Server {
|
||||
init();
|
||||
}
|
||||
|
||||
public WebSocketServer(int port, bool secure)
|
||||
: this(System.Net.IPAddress.Any, port, secure)
|
||||
{
|
||||
}
|
||||
|
||||
public WebSocketServer(System.Net.IPAddress address, int port)
|
||||
: base(address, port)
|
||||
: this(address, port, port == 443 ? true : false)
|
||||
{
|
||||
}
|
||||
|
||||
public WebSocketServer(System.Net.IPAddress address, int port, bool secure)
|
||||
: base(address, port, "/", secure)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -112,7 +122,7 @@ namespace WebSocketSharp.Server {
|
||||
|
||||
protected override void AcceptWebSocket(TcpClient client)
|
||||
{
|
||||
var context = client.AcceptWebSocket();
|
||||
var context = client.AcceptWebSocket(IsSecure);
|
||||
var socket = context.WebSocket;
|
||||
var path = context.Path.UrlDecode();
|
||||
|
||||
|
@@ -40,6 +40,7 @@ namespace WebSocketSharp.Server {
|
||||
|
||||
private Thread _acceptClientThread;
|
||||
private IPAddress _address;
|
||||
private bool _isSecure;
|
||||
private bool _isSelfHost;
|
||||
private int _port;
|
||||
private TcpListener _tcpListener;
|
||||
@@ -67,12 +68,7 @@ namespace WebSocketSharp.Server {
|
||||
init(uri);
|
||||
}
|
||||
|
||||
protected WebSocketServerBase(IPAddress address, int port)
|
||||
: this(address, port, "/")
|
||||
{
|
||||
}
|
||||
|
||||
protected WebSocketServerBase(IPAddress address, int port, string absPath)
|
||||
protected WebSocketServerBase(IPAddress address, int port, string absPath, bool secure)
|
||||
{
|
||||
if (address.IsNull())
|
||||
throw new ArgumentNullException("address");
|
||||
@@ -84,9 +80,20 @@ namespace WebSocketSharp.Server {
|
||||
if (!absPath.IsValidAbsolutePath(out msg))
|
||||
throw new ArgumentException(msg, "absPath");
|
||||
|
||||
_address = address;
|
||||
_port = port <= 0 ? 80 : port;
|
||||
_uri = absPath.ToUri();
|
||||
if ((port == 80 && secure) ||
|
||||
(port == 443 && !secure))
|
||||
{
|
||||
msg = String.Format(
|
||||
"Invalid pair of 'port' and 'secure': {0}, {1}", port, secure);
|
||||
throw new ArgumentException(msg);
|
||||
}
|
||||
|
||||
_address = address;
|
||||
_port = port > 0
|
||||
? port
|
||||
: secure ? 443 : 80;
|
||||
_uri = absPath.ToUri();
|
||||
_isSecure = secure;
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -116,6 +123,12 @@ namespace WebSocketSharp.Server {
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSecure {
|
||||
get {
|
||||
return _isSecure;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSelfHost {
|
||||
get {
|
||||
return _isSelfHost;
|
||||
@@ -185,17 +198,17 @@ namespace WebSocketSharp.Server {
|
||||
|
||||
private void init(Uri uri)
|
||||
{
|
||||
_uri = uri;
|
||||
var scheme = uri.Scheme;
|
||||
var port = uri.Port;
|
||||
var host = uri.DnsSafeHost;
|
||||
var port = uri.Port;
|
||||
var addrs = Dns.GetHostAddresses(host);
|
||||
|
||||
if (port <= 0)
|
||||
port = scheme == "ws" ? 80 : 443;
|
||||
|
||||
_address = addrs[0];
|
||||
_port = port;
|
||||
_uri = uri;
|
||||
_address = addrs[0];
|
||||
_isSecure = scheme == "wss" ? true : false;
|
||||
_port = port > 0
|
||||
? port
|
||||
: _isSecure ? 443 : 80;
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -234,7 +247,7 @@ namespace WebSocketSharp.Server {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Method
|
||||
#region Protected Methods
|
||||
|
||||
protected abstract void AcceptWebSocket(TcpClient client);
|
||||
|
||||
|
@@ -66,13 +66,28 @@ namespace WebSocketSharp.Server {
|
||||
init();
|
||||
}
|
||||
|
||||
public WebSocketServiceHost(int port, bool secure)
|
||||
: this(port, "/", secure)
|
||||
{
|
||||
}
|
||||
|
||||
public WebSocketServiceHost(int port, string absPath)
|
||||
: this(System.Net.IPAddress.Any, port, absPath)
|
||||
{
|
||||
}
|
||||
|
||||
public WebSocketServiceHost(int port, string absPath, bool secure)
|
||||
: this(System.Net.IPAddress.Any, port, absPath, secure)
|
||||
{
|
||||
}
|
||||
|
||||
public WebSocketServiceHost(System.Net.IPAddress address, int port, string absPath)
|
||||
: base(address, port, absPath)
|
||||
: this(address, port, absPath, port == 443 ? true : false)
|
||||
{
|
||||
}
|
||||
|
||||
public WebSocketServiceHost(System.Net.IPAddress address, int port, string absPath, bool secure)
|
||||
: base(address, port, absPath, secure)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -116,7 +131,7 @@ namespace WebSocketSharp.Server {
|
||||
|
||||
protected override void AcceptWebSocket(TcpClient client)
|
||||
{
|
||||
var context = client.AcceptWebSocket();
|
||||
var context = client.AcceptWebSocket(IsSecure);
|
||||
var socket = context.WebSocket;
|
||||
var path = context.Path.UrlDecode();
|
||||
if (path != Uri.GetAbsolutePath().UrlDecode())
|
||||
|
Reference in New Issue
Block a user