[Modify] Throw exceptions

This commit is contained in:
sta 2017-08-09 17:55:17 +09:00
parent 8a095213f6
commit 49d17cfa7b

View File

@ -162,8 +162,19 @@ namespace WebSocketSharp.Server
/// </param> /// </param>
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)
throw new ArgumentNullException ("id");
if (id.Length == 0)
throw new ArgumentException ("An empty string.", "id");
IWebSocketSession session; IWebSocketSession session;
TryGetSession (id, out session); tryGetSession (id, out session);
return session; return session;
} }