public void AddService( string path, WebSocketBehavior webSocketBehavior) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Length == 0) { throw new ArgumentException("An empty string.", "path"); } if (path[0] != '/') { throw new ArgumentException("Not an absolute path.", "path"); } if (path.IndexOfAny(new[] { '?', '#' }) > -1) { var msg = "It includes either or both query and fragment components."; throw new ArgumentException(msg, "path"); } path = HttpUtility.UrlDecode(path).TrimSlashFromEnd(); lock (_sync) { WebSocketServiceHostBase host; if (_hosts.TryGetValue(path, out host)) { throw new ArgumentException("Already in use.", "path"); } host = new WebSocketServiceHost( path, webSocketBehavior, _log ); if (!_clean) { host.KeepClean = false; } if (_waitTime != host.WaitTime) { host.WaitTime = _waitTime; } if (_state == ServerState.Start) { host.Start(); } _hosts.Add(path, host); } }
internal WebSocketServiceHost(string path, WebSocketBehavior webSocketBehavior, Logger log) : base(path, log) { _webSocketBehavior = webSocketBehavior; }