Renamed ServiceManager.cs to ServiceHostManager.cs

This commit is contained in:
sta 2013-01-28 19:42:47 +09:00
parent 95382924e0
commit a171b05740
40 changed files with 64 additions and 80 deletions

Binary file not shown.

Binary file not shown.

View File

@ -28,7 +28,7 @@ namespace Example3
_httpsv.Start(); _httpsv.Start();
Console.WriteLine("HTTP Server listening on port: {0} service path:", _httpsv.Port); Console.WriteLine("HTTP Server listening on port: {0} service path:", _httpsv.Port);
foreach (var path in _httpsv.ServicePath) foreach (var path in _httpsv.ServicePaths)
Console.WriteLine(" {0}", path); Console.WriteLine(" {0}", path);
Console.WriteLine(); Console.WriteLine();

View File

@ -4,7 +4,7 @@
* *
* The MIT License * The MIT License
* *
* Copyright (c) 2012 sta.blockhead * Copyright (c) 2012-2013 sta.blockhead
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -45,7 +45,7 @@ namespace WebSocketSharp.Server {
private HttpListener _listener; private HttpListener _listener;
private int _port; private int _port;
private string _rootPath; private string _rootPath;
private ServiceManager _services; private ServiceHostManager _svcHosts;
#endregion #endregion
@ -70,19 +70,19 @@ namespace WebSocketSharp.Server {
get { return _port; } get { return _port; }
} }
public IEnumerable<string> ServicePath { public IEnumerable<string> ServicePaths {
get { get {
return _services.Path; return _svcHosts.Paths;
} }
} }
public bool Sweeped { public bool Sweeped {
get { get {
return _services.Sweeped; return _svcHosts.Sweeped;
} }
set { set {
_services.Sweeped = value; _svcHosts.Sweeped = value;
} }
} }
@ -136,7 +136,7 @@ namespace WebSocketSharp.Server {
{ {
_isWindows = false; _isWindows = false;
_listener = new HttpListener(); _listener = new HttpListener();
_services = new ServiceManager(); _svcHosts = new ServiceHostManager();
var os = Environment.OSVersion; var os = Environment.OSVersion;
if (os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX) if (os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX)
@ -278,7 +278,7 @@ namespace WebSocketSharp.Server {
var path = wsContext.Path.UrlDecode(); var path = wsContext.Path.UrlDecode();
IServiceHost svcHost; IServiceHost svcHost;
if (!_services.TryGetServiceHost(path, out svcHost)) if (!_svcHosts.TryGetServiceHost(path, out svcHost))
{ {
res.StatusCode = (int)HttpStatusCode.NotImplemented; res.StatusCode = (int)HttpStatusCode.NotImplemented;
return false; return false;
@ -307,7 +307,7 @@ namespace WebSocketSharp.Server {
if (!Sweeped) if (!Sweeped)
svcHost.Sweeped = Sweeped; svcHost.Sweeped = Sweeped;
_services.Add(absPath, svcHost); _svcHosts.Add(absPath, svcHost);
} }
public byte[] GetFile(string path) public byte[] GetFile(string path)
@ -332,7 +332,7 @@ namespace WebSocketSharp.Server {
{ {
_listener.Close(); _listener.Close();
_acceptRequestThread.Join(5 * 1000); _acceptRequestThread.Join(5 * 1000);
_services.Stop(); _svcHosts.Stop();
} }
#endregion #endregion

View File

@ -1,10 +1,10 @@
#region MIT License #region MIT License
/* /*
* ServiceManager.cs * ServiceHostManager.cs
* *
* The MIT License * The MIT License
* *
* Copyright (c) 2012 sta.blockhead * Copyright (c) 2012-2013 sta.blockhead
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -31,20 +31,20 @@ using System.Collections.Generic;
namespace WebSocketSharp.Server { namespace WebSocketSharp.Server {
public class ServiceManager { internal class ServiceHostManager {
#region Field #region Fields
private Dictionary<string, IServiceHost> _services; private Dictionary<string, IServiceHost> _svcHosts;
private bool _sweeped; private bool _sweeped;
#endregion #endregion
#region Constructor #region Constructor
public ServiceManager() public ServiceHostManager()
{ {
_services = new Dictionary<string, IServiceHost>(); _svcHosts = new Dictionary<string, IServiceHost>();
_sweeped = true; _sweeped = true;
} }
@ -54,7 +54,19 @@ namespace WebSocketSharp.Server {
public int Count { public int Count {
get { get {
return _services.Count; return _svcHosts.Count;
}
}
public IEnumerable<string> Paths {
get {
return _svcHosts.Keys;
}
}
public IEnumerable<IServiceHost> ServiceHosts {
get {
return _svcHosts.Values;
} }
} }
@ -67,49 +79,38 @@ namespace WebSocketSharp.Server {
if (_sweeped ^ value) if (_sweeped ^ value)
{ {
_sweeped = value; _sweeped = value;
foreach (var svcHost in _services.Values) foreach (var svcHost in _svcHosts.Values)
svcHost.Sweeped = value; svcHost.Sweeped = value;
} }
} }
} }
public IEnumerable<string> Path {
get {
return _services.Keys;
}
}
public IEnumerable<IServiceHost> ServiceHost {
get {
return _services.Values;
}
}
#endregion #endregion
#region Public Methods #region Public Methods
public void Add(string absPath, IServiceHost svcHost) public void Add(string absPath, IServiceHost svcHost)
{ {
_services.Add(absPath.UrlDecode(), svcHost); _svcHosts.Add(absPath.UrlDecode(), svcHost);
} }
public void Broadcast(string data) public void Broadcast(string data)
{ {
foreach (var svcHost in _services.Values) foreach (var svcHost in _svcHosts.Values)
svcHost.Broadcast(data); svcHost.Broadcast(data);
} }
public void Stop() public void Stop()
{ {
foreach (var svcHost in _services.Values) foreach (var svcHost in _svcHosts.Values)
svcHost.Stop(); svcHost.Stop();
_services.Clear();
_svcHosts.Clear();
} }
public bool TryGetServiceHost(string absPath, out IServiceHost svcHost) public bool TryGetServiceHost(string absPath, out IServiceHost svcHost)
{ {
return _services.TryGetValue(absPath, out svcHost); return _svcHosts.TryGetValue(absPath, out svcHost);
} }
#endregion #endregion

View File

@ -46,7 +46,7 @@ namespace WebSocketSharp.Server {
{ {
#region Field #region Field
private ServiceManager _services; private ServiceHostManager _svcHosts;
#endregion #endregion
@ -155,7 +155,7 @@ namespace WebSocketSharp.Server {
var url = BaseUri.IsAbsoluteUri var url = BaseUri.IsAbsoluteUri
? BaseUri.ToString().TrimEnd('/') ? BaseUri.ToString().TrimEnd('/')
: String.Empty; : String.Empty;
foreach (var path in _services.Path) foreach (var path in _svcHosts.Paths)
yield return url + path; yield return url + path;
} }
} }
@ -168,11 +168,11 @@ namespace WebSocketSharp.Server {
/// </value> /// </value>
public bool Sweeped { public bool Sweeped {
get { get {
return _services.Sweeped; return _svcHosts.Sweeped;
} }
set { set {
_services.Sweeped = value; _svcHosts.Sweeped = value;
} }
} }
@ -182,7 +182,7 @@ namespace WebSocketSharp.Server {
private void init() private void init()
{ {
_services = new ServiceManager(); _svcHosts = new ServiceHostManager();
} }
#endregion #endregion
@ -201,7 +201,7 @@ namespace WebSocketSharp.Server {
var path = context.Path.UrlDecode(); var path = context.Path.UrlDecode();
IServiceHost svcHost; IServiceHost svcHost;
if (!_services.TryGetServiceHost(path, out svcHost)) if (!_svcHosts.TryGetServiceHost(path, out svcHost))
{ {
socket.Close(HttpStatusCode.NotImplemented); socket.Close(HttpStatusCode.NotImplemented);
return; return;
@ -243,7 +243,7 @@ namespace WebSocketSharp.Server {
if (!Sweeped) if (!Sweeped)
svcHost.Sweeped = Sweeped; svcHost.Sweeped = Sweeped;
_services.Add(absPath, svcHost); _svcHosts.Add(absPath, svcHost);
} }
/// <summary> /// <summary>
@ -254,7 +254,7 @@ namespace WebSocketSharp.Server {
/// </param> /// </param>
public void Broadcast(string data) public void Broadcast(string data)
{ {
_services.Broadcast(data); _svcHosts.Broadcast(data);
} }
/// <summary> /// <summary>
@ -263,7 +263,7 @@ namespace WebSocketSharp.Server {
public override void Stop() public override void Stop()
{ {
base.Stop(); base.Stop();
_services.Stop(); _svcHosts.Stop();
} }
#endregion #endregion

View File

@ -284,7 +284,7 @@
<td>[read-only]<div></div></td> <td>[read-only]<div></div></td>
<td> <td>
<b> <b>
<a href="#P:WebSocketSharp.Server.HttpServer.ServicePath">ServicePath</a> <a href="#P:WebSocketSharp.Server.HttpServer.ServicePaths">ServicePaths</a>
</b> </b>
</td> </td>
<td> <td>
@ -831,23 +831,23 @@
<b>Namespace: </b>WebSocketSharp.Server<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div> <b>Namespace: </b>WebSocketSharp.Server<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" /> <hr size="1" />
</blockquote> </blockquote>
<h3 id="P:WebSocketSharp.Server.HttpServer.ServicePath">ServicePath Property</h3> <h3 id="P:WebSocketSharp.Server.HttpServer.ServicePaths">ServicePaths Property</h3>
<blockquote id="P:WebSocketSharp.Server.HttpServer.ServicePath:member"> <blockquote id="P:WebSocketSharp.Server.HttpServer.ServicePaths:member">
<p class="Summary"> <p class="Summary">
<span class="NotEntered">Documentation for this section has not yet been entered.</span> <span class="NotEntered">Documentation for this section has not yet been entered.</span>
</p> </p>
<h2>Syntax</h2> <h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Collections.Generic.IEnumerable`1">IEnumerable&lt;string&gt;</a> <b>ServicePath</b> { get; }</div> <div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Collections.Generic.IEnumerable`1">IEnumerable&lt;string&gt;</a> <b>ServicePaths</b> { get; }</div>
<h4 class="Subsection">Value</h4> <h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.Server.HttpServer.ServicePath:Value"> <blockquote class="SubsectionBox" id="P:WebSocketSharp.Server.HttpServer.ServicePaths:Value">
<span class="NotEntered">Documentation for this section has not yet been entered.</span> <span class="NotEntered">Documentation for this section has not yet been entered.</span>
</blockquote> </blockquote>
<h2 class="Section">Remarks</h2> <h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.Server.HttpServer.ServicePath:Remarks"> <div class="SectionBox" id="P:WebSocketSharp.Server.HttpServer.ServicePaths:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span> <span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div> </div>
<h2 class="Section">Requirements</h2> <h2 class="Section">Requirements</h2>
<div class="SectionBox" id="P:WebSocketSharp.Server.HttpServer.ServicePath:Version Information"> <div class="SectionBox" id="P:WebSocketSharp.Server.HttpServer.ServicePaths:Version Information">
<b>Namespace: </b>WebSocketSharp.Server<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div> <b>Namespace: </b>WebSocketSharp.Server<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" /> <hr size="1" />
</blockquote> </blockquote>

View File

@ -226,14 +226,6 @@
<span class="NotEntered">Documentation for this section has not yet been entered.</span> <span class="NotEntered">Documentation for this section has not yet been entered.</span>
</td> </td>
</tr> </tr>
<tr valign="top">
<td>
<a href="./ServiceManager.html">ServiceManager</a>
</td>
<td>
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</td>
</tr>
<tr valign="top"> <tr valign="top">
<td> <td>
<a href="./SessionManager.html">SessionManager</a> <a href="./SessionManager.html">SessionManager</a>

View File

@ -474,14 +474,6 @@
<span class="NotEntered">Documentation for this section has not yet been entered.</span> <span class="NotEntered">Documentation for this section has not yet been entered.</span>
</td> </td>
</tr> </tr>
<tr valign="top">
<td>
<a href="WebSocketSharp.Server/ServiceManager.html">ServiceManager</a>
</td>
<td>
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</td>
</tr>
<tr valign="top"> <tr valign="top">
<td> <td>
<a href="WebSocketSharp.Server/SessionManager.html">SessionManager</a> <a href="WebSocketSharp.Server/SessionManager.html">SessionManager</a>

View File

@ -211,9 +211,9 @@
<remarks>To be added.</remarks> <remarks>To be added.</remarks>
</Docs> </Docs>
</Member> </Member>
<Member MemberName="ServicePath"> <Member MemberName="ServicePaths">
<MemberSignature Language="C#" Value="public System.Collections.Generic.IEnumerable&lt;string&gt; ServicePath { get; }" /> <MemberSignature Language="C#" Value="public System.Collections.Generic.IEnumerable&lt;string&gt; ServicePaths { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Generic.IEnumerable`1&lt;string&gt; ServicePath" /> <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Generic.IEnumerable`1&lt;string&gt; ServicePaths" />
<MemberType>Property</MemberType> <MemberType>Property</MemberType>
<ReturnValue> <ReturnValue>
<ReturnType>System.Collections.Generic.IEnumerable&lt;System.String&gt;</ReturnType> <ReturnType>System.Collections.Generic.IEnumerable&lt;System.String&gt;</ReturnType>

View File

@ -1,6 +1,6 @@
<Overview> <Overview>
<Assemblies> <Assemblies>
<Assembly Name="websocket-sharp" Version="1.0.2.28541"> <Assembly Name="websocket-sharp" Version="1.0.2.34976">
<AssemblyPublicKey>[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 11 00 00 00 29 17 fb 89 fe c3 91 f7 2b cb 8b e2 61 d2 3f 05 93 6d 65 a8 9e 63 72 a6 f5 d5 2c f2 9d 20 fa 0b c0 70 6a f6 88 7e 8b 90 3f 39 f5 76 c8 48 e0 bb 7b b2 7b ed d3 10 a7 1a 0f 70 98 0f 7f f4 4b 53 09 d2 a5 ef 36 c3 56 b4 aa f0 91 72 63 25 07 89 e0 93 3e 3f 2e f2 b9 73 0e 12 15 5d 43 56 c3 f4 70 a5 89 fe f7 f6 ac 3e 77 c2 d8 d0 84 91 f4 0c d1 f3 8e dc c3 c3 b8 38 3d 0c bf 17 de 20 78 c1 ]</AssemblyPublicKey> <AssemblyPublicKey>[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 11 00 00 00 29 17 fb 89 fe c3 91 f7 2b cb 8b e2 61 d2 3f 05 93 6d 65 a8 9e 63 72 a6 f5 d5 2c f2 9d 20 fa 0b c0 70 6a f6 88 7e 8b 90 3f 39 f5 76 c8 48 e0 bb 7b b2 7b ed d3 10 a7 1a 0f 70 98 0f 7f f4 4b 53 09 d2 a5 ef 36 c3 56 b4 aa f0 91 72 63 25 07 89 e0 93 3e 3f 2e f2 b9 73 0e 12 15 5d 43 56 c3 f4 70 a5 89 fe f7 f6 ac 3e 77 c2 d8 d0 84 91 f4 0c d1 f3 8e dc c3 c3 b8 38 3d 0c bf 17 de 20 78 c1 ]</AssemblyPublicKey>
<Attributes> <Attributes>
<Attribute> <Attribute>
@ -70,7 +70,6 @@
<Type Name="HttpServer" Kind="Class" /> <Type Name="HttpServer" Kind="Class" />
<Type Name="IServiceHost" Kind="Interface" /> <Type Name="IServiceHost" Kind="Interface" />
<Type Name="ResponseEventArgs" Kind="Class" /> <Type Name="ResponseEventArgs" Kind="Class" />
<Type Name="ServiceManager" Kind="Class" />
<Type Name="SessionManager" Kind="Class" /> <Type Name="SessionManager" Kind="Class" />
<Type Name="WebSocketServer" Kind="Class" /> <Type Name="WebSocketServer" Kind="Class" />
<Type Name="WebSocketServerBase" Kind="Class" /> <Type Name="WebSocketServerBase" Kind="Class" />

View File

@ -109,7 +109,6 @@
<Compile Include="Server\IServiceHost.cs" /> <Compile Include="Server\IServiceHost.cs" />
<Compile Include="Server\SessionManager.cs" /> <Compile Include="Server\SessionManager.cs" />
<Compile Include="Server\WebSocketServiceHost.cs" /> <Compile Include="Server\WebSocketServiceHost.cs" />
<Compile Include="Server\ServiceManager.cs" />
<Compile Include="CloseStatusCode.cs" /> <Compile Include="CloseStatusCode.cs" />
<Compile Include="Fin.cs" /> <Compile Include="Fin.cs" />
<Compile Include="Mask.cs" /> <Compile Include="Mask.cs" />
@ -120,6 +119,7 @@
<Compile Include="Net\WebSockets\HttpListenerWebSocketContext.cs" /> <Compile Include="Net\WebSockets\HttpListenerWebSocketContext.cs" />
<Compile Include="Net\WebSockets\TcpListenerWebSocketContext.cs" /> <Compile Include="Net\WebSockets\TcpListenerWebSocketContext.cs" />
<Compile Include="Net\WebSockets\WebSocketContext.cs" /> <Compile Include="Net\WebSockets\WebSocketContext.cs" />
<Compile Include="Server\ServiceHostManager.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>

Binary file not shown.