diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index c61e476f..f2fe9ec8 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -58,6 +58,8 @@ namespace WebSocketSharp.Net private static readonly Dictionary> _addressToEndpoints; + private static readonly Dictionary _endpoints; + #endregion #region Static Constructor @@ -65,6 +67,7 @@ namespace WebSocketSharp.Net static EndPointManager () { _addressToEndpoints = new Dictionary> (); + _endpoints = new Dictionary (); } #endregion @@ -186,6 +189,20 @@ namespace WebSocketSharp.Net #region Internal Methods + internal static bool RemoveEndPoint (IPEndPoint endpoint) + { + lock (((ICollection) _endpoints).SyncRoot) { + EndPointListener lsnr; + if (!_endpoints.TryGetValue (endpoint, out lsnr)) + return false; + + _endpoints.Remove (endpoint); + lsnr.Close (); + + return true; + } + } + internal static bool RemoveEndPoint (IPAddress address, int port) { lock (((ICollection) _addressToEndpoints).SyncRoot) {