diff --git a/Example/Example.pidb b/Example/Example.pidb index 3d04d80d..a94ff962 100644 Binary files a/Example/Example.pidb and b/Example/Example.pidb differ diff --git a/Example/Program.cs b/Example/Program.cs index df1a5cfe..acd427db 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -73,11 +73,11 @@ namespace Example ThreadPool.QueueUserWorkItem(notifyMsg); - using (WebSocket ws = new WebSocket("ws://echo.websocket.org", "echo")) + //using (WebSocket ws = new WebSocket("ws://echo.websocket.org", "echo")) //using (WebSocket ws = new WebSocket("wss://echo.websocket.org", "echo")) //using (WebSocket ws = new WebSocket("ws://localhost:4649")) //using (WebSocket ws = new WebSocket("ws://localhost:4649/Echo")) - //using (WebSocket ws = new WebSocket("ws://localhost:4649/Echo?name=nobita")) + using (WebSocket ws = new WebSocket("ws://localhost:4649/Echo?name=nobita")) //using (WebSocket ws = new WebSocket("ws://localhost:4649/エコー?name=のび太")) //using (WebSocket ws = new WebSocket("ws://localhost:4649/Chat")) //using (WebSocket ws = new WebSocket("ws://localhost:4649/Chat?name=nobita")) diff --git a/Example/bin/Debug_Ubuntu/example.exe b/Example/bin/Debug_Ubuntu/example.exe index d5ed725c..74766c94 100755 Binary files a/Example/bin/Debug_Ubuntu/example.exe and b/Example/bin/Debug_Ubuntu/example.exe differ diff --git a/Example/bin/Debug_Ubuntu/example.exe.mdb b/Example/bin/Debug_Ubuntu/example.exe.mdb index 0df28e0f..be7c63a4 100644 Binary files a/Example/bin/Debug_Ubuntu/example.exe.mdb and b/Example/bin/Debug_Ubuntu/example.exe.mdb differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll b/Example/bin/Debug_Ubuntu/websocket-sharp.dll index f06b8384..0c86b374 100755 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 672db19b..38dc6da5 100644 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe b/Example1/bin/Debug_Ubuntu/example1.exe index d83f214e..c9be303f 100755 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe and b/Example1/bin/Debug_Ubuntu/example1.exe differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe.mdb b/Example1/bin/Debug_Ubuntu/example1.exe.mdb index 2d8b8c1a..23b85d00 100644 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe.mdb and b/Example1/bin/Debug_Ubuntu/example1.exe.mdb differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll index f06b8384..0c86b374 100755 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 672db19b..38dc6da5 100644 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example2/Example2.pidb b/Example2/Example2.pidb index ecc3a5f8..f07c6064 100644 Binary files a/Example2/Example2.pidb and b/Example2/Example2.pidb differ diff --git a/Example2/Program.cs b/Example2/Program.cs index 8438dcdd..e828fbce 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -30,16 +30,19 @@ namespace Example2 /// Multi services server var wssv = new WebSocketServer(4649); + //var wssv = new WebSocketServer("ws://localhost:4649"); + //wssv.Sweeped = false; // Stop the Sweep inactive session Timer. wssv.AddService("/Echo"); - wssv.AddService("/エコー"); wssv.AddService("/Chat"); - wssv.AddService("/チャット"); - //wssv.Sweeped = false; // Must be set after any AddService methods done. + //wssv.AddService("/エコー"); + //wssv.AddService("/チャット"); wssv.Start(); Console.WriteLine( - "WebSocket Server listening on port: {0}\n", wssv.Port); - + "WebSocket Server listening on port: {0} service path:", wssv.Port); + foreach (var path in wssv.ServicePath) + Console.WriteLine(" {0}", path); + Console.WriteLine(); Console.WriteLine("Press any key to stop server..."); Console.ReadLine(); diff --git a/Example2/bin/Debug_Ubuntu/example2.exe b/Example2/bin/Debug_Ubuntu/example2.exe index 7039eba6..0fe39737 100755 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe and b/Example2/bin/Debug_Ubuntu/example2.exe differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe.mdb b/Example2/bin/Debug_Ubuntu/example2.exe.mdb index 53dd27f3..64345177 100644 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe.mdb and b/Example2/bin/Debug_Ubuntu/example2.exe.mdb differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll index f06b8384..0c86b374 100755 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 672db19b..38dc6da5 100644 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example3/Example3.pidb b/Example3/Example3.pidb index 5a095f9c..2c4bf55e 100644 Binary files a/Example3/Example3.pidb and b/Example3/Example3.pidb differ diff --git a/Example3/Program.cs b/Example3/Program.cs index 7da77afd..3811dcd6 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -12,9 +12,9 @@ namespace Example3 public static void Main(string[] args) { _httpsv = new HttpServer(4649); + //_httpsv.Sweeped = false; // Stop the Sweep inactive session Timer. _httpsv.AddService("/Echo"); _httpsv.AddService("/Chat"); - //_httpsv.Sweeped = false; // Must be set after any AddService methods done. _httpsv.OnGet += (sender, e) => { @@ -27,7 +27,10 @@ namespace Example3 }; _httpsv.Start(); - Console.WriteLine("HTTP Server listening on port: {0}\n", _httpsv.Port); + Console.WriteLine("HTTP Server listening on port: {0} service path:", _httpsv.Port); + foreach (var path in _httpsv.ServicePath) + Console.WriteLine(" {0}", path); + Console.WriteLine(); Console.WriteLine("Press any key to stop server..."); Console.ReadLine(); diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe b/Example3/bin/Debug_Ubuntu/Example3.exe index 567afa7d..c2db4d8d 100755 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe and b/Example3/bin/Debug_Ubuntu/Example3.exe differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe.mdb b/Example3/bin/Debug_Ubuntu/Example3.exe.mdb index c11cafa9..64f4ca81 100644 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe.mdb and b/Example3/bin/Debug_Ubuntu/Example3.exe.mdb differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll index f06b8384..0c86b374 100755 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 672db19b..38dc6da5 100644 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b54c4535..a46924a6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -27,6 +27,7 @@ #endregion using System; +using System.Collections.Generic; using System.Configuration; using System.Diagnostics; using System.IO; @@ -69,6 +70,12 @@ namespace WebSocketSharp.Server { get { return _port; } } + public IEnumerable ServicePath { + get { + return _services.Path; + } + } + public bool Sweeped { get { return _services.Sweeped; @@ -296,6 +303,10 @@ namespace WebSocketSharp.Server { } var svcHost = new WebSocketServiceHost(); + svcHost.Uri = absPath.ToUri(); + if (!Sweeped) + svcHost.Sweeped = Sweeped; + _services.Add(absPath, svcHost); } diff --git a/websocket-sharp/Server/ServiceManager.cs b/websocket-sharp/Server/ServiceManager.cs index 4ca8e3de..f23bf734 100644 --- a/websocket-sharp/Server/ServiceManager.cs +++ b/websocket-sharp/Server/ServiceManager.cs @@ -64,7 +64,7 @@ namespace WebSocketSharp.Server { } set { - if (value ^ _sweeped) + if (_sweeped ^ value) { _sweeped = value; foreach (var svcHost in _services.Values) @@ -73,6 +73,18 @@ namespace WebSocketSharp.Server { } } + public IEnumerable Path { + get { + return _services.Keys; + } + } + + public IEnumerable ServiceHost { + get { + return _services.Values; + } + } + #endregion #region Public Methods diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8d753cc4..8cc96cb5 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -29,6 +29,7 @@ #endregion using System; +using System.Collections.Generic; using System.Net.Sockets; using WebSocketSharp.Net; @@ -76,6 +77,16 @@ namespace WebSocketSharp.Server { #region Property + public IEnumerable ServicePath { + get { + var url = BaseUri.IsAbsoluteUri + ? BaseUri.ToString().TrimEnd('/') + : String.Empty; + foreach (var path in _services.Path) + yield return url + path; + } + } + public bool Sweeped { get { return _services.Sweeped; @@ -133,6 +144,12 @@ namespace WebSocketSharp.Server { } var svcHost = new WebSocketServiceHost(); + svcHost.Uri = BaseUri.IsAbsoluteUri + ? new Uri(BaseUri, absPath) + : absPath.ToUri(); + if (!Sweeped) + svcHost.Sweeped = Sweeped; + _services.Add(absPath, svcHost); } diff --git a/websocket-sharp/Server/WebSocketServerBase.cs b/websocket-sharp/Server/WebSocketServerBase.cs index e66a7ba7..7f658ab7 100644 --- a/websocket-sharp/Server/WebSocketServerBase.cs +++ b/websocket-sharp/Server/WebSocketServerBase.cs @@ -100,6 +100,10 @@ namespace WebSocketSharp.Server { get { return _uri; } + + set { + _uri = value; + } } #endregion diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 3be9fe72..5132453c 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -95,6 +95,10 @@ namespace WebSocketSharp.Server { get { return BaseUri; } + + internal set { + BaseUri = value; + } } #endregion @@ -122,7 +126,7 @@ namespace WebSocketSharp.Server { } if (Uri.IsAbsoluteUri) - socket.Url = new Uri(Uri, path); + socket.Url = Uri; BindWebSocket(socket); } diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index f06b8384..0c86b374 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 672db19b..38dc6da5 100644 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index 130e0515..c8eb772a 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ