From b9c2eefaff8e40f62318be909cab71489236667f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jun 2016 15:33:47 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 4db251ec..fe6979a5 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -203,6 +203,26 @@ namespace WebSocketSharp.Net } } + internal static bool RemoveEndPoint (IPAddress address, int port) + { + lock (((ICollection) _addressToEndpoints).SyncRoot) { + Dictionary endpoints; + if (!_addressToEndpoints.TryGetValue (address, out endpoints)) + return false; + + EndPointListener lsnr; + if (!endpoints.TryGetValue (port, out lsnr)) + return false; + + endpoints.Remove (port); + if (endpoints.Count == 0) + _addressToEndpoints.Remove (address); + + lsnr.Close (); + return true; + } + } + #endregion #region Public Methods