[Modify] Use List
This commit is contained in:
parent
4ca94607be
commit
fa1538250c
@ -64,7 +64,7 @@ namespace WebSocketSharp.Net
|
|||||||
private List<HttpListenerPrefix> _all; // host == '+'
|
private List<HttpListenerPrefix> _all; // host == '+'
|
||||||
private static readonly string _defaultCertFolderPath;
|
private static readonly string _defaultCertFolderPath;
|
||||||
private IPEndPoint _endpoint;
|
private IPEndPoint _endpoint;
|
||||||
private Dictionary<HttpListenerPrefix, HttpListener> _prefixes;
|
private List<HttpListenerPrefix> _prefixes;
|
||||||
private bool _secure;
|
private bool _secure;
|
||||||
private Socket _socket;
|
private Socket _socket;
|
||||||
private ServerSslConfiguration _sslConfig;
|
private ServerSslConfiguration _sslConfig;
|
||||||
@ -114,7 +114,7 @@ namespace WebSocketSharp.Net
|
|||||||
_sslConfig.ServerCertificate = cert;
|
_sslConfig.ServerCertificate = cert;
|
||||||
}
|
}
|
||||||
|
|
||||||
_prefixes = new Dictionary<HttpListenerPrefix, HttpListener> ();
|
_prefixes = new List<HttpListenerPrefix> ();
|
||||||
_unregistered = new Dictionary<HttpConnection, HttpConnection> ();
|
_unregistered = new Dictionary<HttpConnection, HttpConnection> ();
|
||||||
_unregisteredSync = ((ICollection) _unregistered).SyncRoot;
|
_unregisteredSync = ((ICollection) _unregistered).SyncRoot;
|
||||||
|
|
||||||
@ -377,9 +377,10 @@ namespace WebSocketSharp.Net
|
|||||||
path += "/";
|
path += "/";
|
||||||
|
|
||||||
if (host != null && host.Length > 0) {
|
if (host != null && host.Length > 0) {
|
||||||
|
var prefs = _prefixes;
|
||||||
var bestLen = -1;
|
var bestLen = -1;
|
||||||
|
|
||||||
foreach (var pref in _prefixes.Keys) {
|
foreach (var pref in prefs) {
|
||||||
if (dns) {
|
if (dns) {
|
||||||
var prefHost = pref.Host;
|
var prefHost = pref.Host;
|
||||||
var prefDns = Uri.CheckHostName (prefHost) == UriHostNameType.Dns;
|
var prefDns = Uri.CheckHostName (prefHost) == UriHostNameType.Dns;
|
||||||
@ -459,13 +460,14 @@ namespace WebSocketSharp.Net
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<HttpListenerPrefix, HttpListener> prefs, prefs2;
|
List<HttpListenerPrefix> prefs, prefs2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
prefs = _prefixes;
|
prefs = _prefixes;
|
||||||
|
var idx = prefs.IndexOf (prefix);
|
||||||
|
|
||||||
if (prefs.ContainsKey (prefix)) {
|
if (idx > -1) {
|
||||||
if (prefs[prefix] != prefix.Listener) {
|
if (prefs[idx].Listener != prefix.Listener) {
|
||||||
var msg = String.Format (
|
var msg = String.Format (
|
||||||
"There is another listener for {0}.", prefix
|
"There is another listener for {0}.", prefix
|
||||||
);
|
);
|
||||||
@ -476,8 +478,8 @@ namespace WebSocketSharp.Net
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs2 = new Dictionary<HttpListenerPrefix, HttpListener> (prefs);
|
prefs2 = new List<HttpListenerPrefix> (prefs);
|
||||||
prefs2[prefix] = prefix.Listener;
|
prefs2.Add (prefix);
|
||||||
}
|
}
|
||||||
while (
|
while (
|
||||||
Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs
|
Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs
|
||||||
@ -553,15 +555,15 @@ namespace WebSocketSharp.Net
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<HttpListenerPrefix, HttpListener> prefs, prefs2;
|
List<HttpListenerPrefix> prefs, prefs2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
prefs = _prefixes;
|
prefs = _prefixes;
|
||||||
|
|
||||||
if (!prefs.ContainsKey (prefix))
|
if (!prefs.Contains (prefix))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
prefs2 = new Dictionary<HttpListenerPrefix, HttpListener> (prefs);
|
prefs2 = new List<HttpListenerPrefix> (prefs);
|
||||||
prefs2.Remove (prefix);
|
prefs2.Remove (prefix);
|
||||||
}
|
}
|
||||||
while (
|
while (
|
||||||
|
Loading…
Reference in New Issue
Block a user