[Modify] Return false instead of throwing an exception
This commit is contained in:
parent
0425a42cab
commit
ea03410968
@ -167,9 +167,6 @@ namespace WebSocketSharp.Server
|
|||||||
/// A <see cref="string"/> that represents the ID of
|
/// A <see cref="string"/> that represents the ID of
|
||||||
/// the session to find.
|
/// the session to find.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <exception cref="InvalidOperationException">
|
|
||||||
/// The current state of the manager is not Start.
|
|
||||||
/// </exception>
|
|
||||||
/// <exception cref="ArgumentNullException">
|
/// <exception cref="ArgumentNullException">
|
||||||
/// <paramref name="id"/> is <see langword="null"/>.
|
/// <paramref name="id"/> is <see langword="null"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
@ -178,11 +175,6 @@ namespace WebSocketSharp.Server
|
|||||||
/// </exception>
|
/// </exception>
|
||||||
public IWebSocketSession this[string id] {
|
public IWebSocketSession this[string id] {
|
||||||
get {
|
get {
|
||||||
if (_state != ServerState.Start) {
|
|
||||||
var msg = "The current state of the manager is not Start.";
|
|
||||||
throw new InvalidOperationException (msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id == null)
|
if (id == null)
|
||||||
throw new ArgumentNullException ("id");
|
throw new ArgumentNullException ("id");
|
||||||
|
|
||||||
@ -336,8 +328,17 @@ namespace WebSocketSharp.Server
|
|||||||
|
|
||||||
private bool tryGetSession (string id, out IWebSocketSession session)
|
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);
|
return _sessions.TryGetValue (id, out session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -1079,9 +1080,6 @@ namespace WebSocketSharp.Server
|
|||||||
/// the information in the session.
|
/// the information in the session.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <exception cref="InvalidOperationException">
|
|
||||||
/// The current state of the manager is not Start.
|
|
||||||
/// </exception>
|
|
||||||
/// <exception cref="ArgumentNullException">
|
/// <exception cref="ArgumentNullException">
|
||||||
/// <paramref name="id"/> is <see langword="null"/>.
|
/// <paramref name="id"/> is <see langword="null"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
@ -1090,11 +1088,6 @@ namespace WebSocketSharp.Server
|
|||||||
/// </exception>
|
/// </exception>
|
||||||
public bool TryGetSession (string id, out IWebSocketSession session)
|
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)
|
if (id == null)
|
||||||
throw new ArgumentNullException ("id");
|
throw new ArgumentNullException ("id");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user