diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ab3b2739..6c57cd29 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -167,9 +167,6 @@ namespace WebSocketSharp.Server /// A that represents the ID of /// the session to find. /// - /// - /// The current state of the manager is not Start. - /// /// /// is . /// @@ -178,11 +175,6 @@ namespace WebSocketSharp.Server /// public IWebSocketSession this[string id] { get { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - if (id == null) throw new ArgumentNullException ("id"); @@ -336,8 +328,17 @@ namespace WebSocketSharp.Server private bool tryGetSession (string id, out IWebSocketSession session) { - lock (_sync) + session = null; + + if (_state != ServerState.Start) + return false; + + lock (_sync) { + if (_state != ServerState.Start) + return false; + return _sessions.TryGetValue (id, out session); + } } #endregion @@ -1079,9 +1080,6 @@ namespace WebSocketSharp.Server /// the information in the session. /// /// - /// - /// The current state of the manager is not Start. - /// /// /// is . /// @@ -1090,11 +1088,6 @@ namespace WebSocketSharp.Server /// public bool TryGetSession (string id, out IWebSocketSession session) { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - if (id == null) throw new ArgumentNullException ("id");