Renamed the Sweeping property to the KeepClean property

master
sta 13 years ago
parent ef17cabdd3
commit df2726ce9d

@ -26,7 +26,7 @@ namespace Example2 {
#if DEBUG #if DEBUG
wssv.Log.Level = LogLevel.TRACE; wssv.Log.Level = LogLevel.TRACE;
#endif #endif
//wssv.Sweeping = false; //wssv.KeepClean = false;
wssv.Start (); wssv.Start ();
Console.WriteLine ( Console.WriteLine (
@ -45,7 +45,7 @@ namespace Example2 {
//var file = ConfigurationManager.AppSettings ["ServerCertFile"]; //var file = ConfigurationManager.AppSettings ["ServerCertFile"];
//var password = ConfigurationManager.AppSettings ["CertFilePassword"]; //var password = ConfigurationManager.AppSettings ["CertFilePassword"];
//wssv.Certificate = new X509Certificate2 (file, password); //wssv.Certificate = new X509Certificate2 (file, password);
//wssv.Sweeping = false; //wssv.KeepClean = false;
wssv.AddWebSocketService<Echo> ("/Echo"); wssv.AddWebSocketService<Echo> ("/Echo");
wssv.AddWebSocketService<Chat> ("/Chat"); wssv.AddWebSocketService<Chat> ("/Chat");
//wssv.AddWebSocketService<Echo> ("/エコー"); //wssv.AddWebSocketService<Echo> ("/エコー");

@ -17,7 +17,7 @@ namespace Example3
_httpsv.Log.Level = LogLevel.TRACE; _httpsv.Log.Level = LogLevel.TRACE;
#endif #endif
_httpsv.RootPath = ConfigurationManager.AppSettings ["RootPath"]; _httpsv.RootPath = ConfigurationManager.AppSettings ["RootPath"];
//_httpsv.Sweeping = false; //_httpsv.KeepClean = false;
_httpsv.AddWebSocketService<Echo> ("/Echo"); _httpsv.AddWebSocketService<Echo> ("/Echo");
_httpsv.AddWebSocketService<Chat> ("/Chat"); _httpsv.AddWebSocketService<Chat> ("/Chat");

@ -96,6 +96,24 @@ namespace WebSocketSharp.Server
} }
} }
/// <summary>
/// Gets or sets a value indicating whether the server cleans up the inactive WebSocket service
/// instances periodically.
/// </summary>
/// <value>
/// <c>true</c> if the server cleans up the inactive WebSocket service instances every 60 seconds;
/// otherwise, <c>false</c>. The default value is <c>true</c>.
/// </value>
public bool KeepClean {
get {
return _svcHosts.KeepClean;
}
set {
_svcHosts.KeepClean = value;
}
}
/// <summary> /// <summary>
/// Gets the logging functions. /// Gets the logging functions.
/// </summary> /// </summary>
@ -155,24 +173,6 @@ namespace WebSocketSharp.Server
} }
} }
/// <summary>
/// Gets or sets a value indicating whether the server cleans up the inactive WebSocket service
/// instances periodically.
/// </summary>
/// <value>
/// <c>true</c> if the server cleans up the inactive WebSocket service instances every 60 seconds;
/// otherwise, <c>false</c>. The default value is <c>true</c>.
/// </value>
public bool Sweeping {
get {
return _svcHosts.Sweeping;
}
set {
_svcHosts.Sweeping = value;
}
}
#endregion #endregion
#region Public Events #region Public Events
@ -412,8 +412,8 @@ namespace WebSocketSharp.Server
var svcHost = new WebSocketServiceHost<T> (_logger); var svcHost = new WebSocketServiceHost<T> (_logger);
svcHost.Uri = absPath.ToUri (); svcHost.Uri = absPath.ToUri ();
if (!Sweeping) if (!KeepClean)
svcHost.Sweeping = false; svcHost.KeepClean = false;
_svcHosts.Add (absPath, svcHost); _svcHosts.Add (absPath, svcHost);
} }

@ -46,7 +46,7 @@ namespace WebSocketSharp.Server {
/// <c>true</c> if the WebSocket service host cleans up the inactive service instances periodically; /// <c>true</c> if the WebSocket service host cleans up the inactive service instances periodically;
/// otherwise, <c>false</c>. /// otherwise, <c>false</c>.
/// </value> /// </value>
bool Sweeping { get; set; } bool KeepClean { get; set; }
/// <summary> /// <summary>
/// Binds the specified <see cref="WebSocketContext"/> to a <see cref="WebSocketService"/> instance. /// Binds the specified <see cref="WebSocketContext"/> to a <see cref="WebSocketService"/> instance.

@ -35,8 +35,8 @@ namespace WebSocketSharp.Server {
#region Private Fields #region Private Fields
private bool _keepClean;
private Dictionary<string, IServiceHost> _svcHosts; private Dictionary<string, IServiceHost> _svcHosts;
private bool _sweeping;
#endregion #endregion
@ -44,8 +44,8 @@ namespace WebSocketSharp.Server {
public ServiceHostManager() public ServiceHostManager()
{ {
_keepClean = true;
_svcHosts = new Dictionary<string, IServiceHost>(); _svcHosts = new Dictionary<string, IServiceHost>();
_sweeping = true;
} }
#endregion #endregion
@ -58,30 +58,30 @@ namespace WebSocketSharp.Server {
} }
} }
public IEnumerable<string> Paths { public bool KeepClean {
get { get {
return _svcHosts.Keys; return _keepClean;
} }
}
public IEnumerable<IServiceHost> ServiceHosts { set {
get { if (_keepClean ^ value)
return _svcHosts.Values; {
_keepClean = value;
foreach (var svcHost in _svcHosts.Values)
svcHost.KeepClean = value;
}
} }
} }
public bool Sweeping { public IEnumerable<string> Paths {
get { get {
return _sweeping; return _svcHosts.Keys;
} }
}
set { public IEnumerable<IServiceHost> ServiceHosts {
if (_sweeping ^ value) get {
{ return _svcHosts.Values;
_sweeping = value;
foreach (var svcHost in _svcHosts.Values)
svcHost.Sweeping = value;
}
} }
} }

@ -145,37 +145,37 @@ namespace WebSocketSharp.Server {
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// Gets the collection of paths associated with the every WebSocket services that the server provides. /// Gets or sets a value indicating whether the server cleans up the inactive WebSocket service
/// instances periodically.
/// </summary> /// </summary>
/// <value> /// <value>
/// An IEnumerable&lt;string&gt; that contains the collection of paths. /// <c>true</c> if the server cleans up the inactive WebSocket service instances every 60 seconds;
/// otherwise, <c>false</c>. The default value is <c>true</c>.
/// </value> /// </value>
public IEnumerable<string> ServicePaths { public bool KeepClean {
get { get {
var url = BaseUri.IsAbsoluteUri return _svcHosts.KeepClean;
? BaseUri.ToString().TrimEnd('/') }
: String.Empty;
foreach (var path in _svcHosts.Paths) set {
yield return url + path; _svcHosts.KeepClean = value;
} }
} }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the server cleans up the inactive WebSocket service /// Gets the collection of paths associated with the every WebSocket services that the server provides.
/// instances periodically.
/// </summary> /// </summary>
/// <value> /// <value>
/// <c>true</c> if the server cleans up the inactive WebSocket service instances every 60 seconds; /// An IEnumerable&lt;string&gt; that contains the collection of paths.
/// otherwise, <c>false</c>. The default value is <c>true</c>.
/// </value> /// </value>
public bool Sweeping { public IEnumerable<string> ServicePaths {
get { get {
return _svcHosts.Sweeping; var url = BaseUri.IsAbsoluteUri
} ? BaseUri.ToString().TrimEnd('/')
: String.Empty;
set { foreach (var path in _svcHosts.Paths)
_svcHosts.Sweeping = value; yield return url + path;
} }
} }
@ -238,8 +238,8 @@ namespace WebSocketSharp.Server {
? new Uri(BaseUri, absPath) ? new Uri(BaseUri, absPath)
: absPath.ToUri(); : absPath.ToUri();
if (!Sweeping) if (!KeepClean)
svcHost.Sweeping = false; svcHost.KeepClean = false;
_svcHosts.Add(absPath, svcHost); _svcHosts.Add(absPath, svcHost);
} }

@ -191,13 +191,13 @@ namespace WebSocketSharp.Server {
/// <c>true</c> if the server cleans up the inactive WebSocket service instances every 60 seconds; /// <c>true</c> if the server cleans up the inactive WebSocket service instances every 60 seconds;
/// otherwise, <c>false</c>. The default value is <c>true</c>. /// otherwise, <c>false</c>. The default value is <c>true</c>.
/// </value> /// </value>
public bool Sweeping { public bool KeepClean {
get { get {
return _sessions.Sweeping; return _sessions.KeepClean;
} }
set { set {
_sessions.Sweeping = value; _sessions.KeepClean = value;
} }
} }

@ -138,10 +138,10 @@ namespace WebSocketSharp.Server
/// the inactive <see cref="WebSocketService"/> instances periodically. /// the inactive <see cref="WebSocketService"/> instances periodically.
/// </summary> /// </summary>
/// <value> /// <value>
/// <c>true</c> if the <see cref="WebSocketServiceManager"/> cleans up /// <c>true</c> if the <see cref="WebSocketServiceManager"/> cleans up the inactive
/// the inactive <see cref="WebSocketService"/> instances every 60 seconds; otherwise, <c>false</c>. /// <see cref="WebSocketService"/> instances every 60 seconds; otherwise, <c>false</c>.
/// </value> /// </value>
public bool Sweeping { public bool KeepClean {
get { get {
return _sweepTimer.Enabled; return _sweepTimer.Enabled;
} }

Loading…
Cancel
Save