Browse Source

Fixed HttpServer.cs

pull/14/head
sta 13 years ago
parent
commit
9730e2a9ff
  1. BIN
      Example/bin/Debug_Ubuntu/example.exe
  2. BIN
      Example/bin/Debug_Ubuntu/example.exe.mdb
  3. BIN
      Example/bin/Debug_Ubuntu/websocket-sharp.dll
  4. BIN
      Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
  5. BIN
      Example1/bin/Debug_Ubuntu/example1.exe
  6. BIN
      Example1/bin/Debug_Ubuntu/example1.exe.mdb
  7. BIN
      Example1/bin/Debug_Ubuntu/websocket-sharp.dll
  8. BIN
      Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
  9. BIN
      Example2/bin/Debug_Ubuntu/example2.exe
  10. BIN
      Example2/bin/Debug_Ubuntu/example2.exe.mdb
  11. BIN
      Example2/bin/Debug_Ubuntu/websocket-sharp.dll
  12. BIN
      Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
  13. BIN
      Example3/bin/Debug_Ubuntu/Example3.exe
  14. BIN
      Example3/bin/Debug_Ubuntu/Example3.exe.mdb
  15. BIN
      Example3/bin/Debug_Ubuntu/websocket-sharp.dll
  16. BIN
      Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
  17. 33
      websocket-sharp/Server/HttpServer.cs
  18. BIN
      websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll
  19. BIN
      websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
  20. BIN
      websocket-sharp/websocket-sharp.pidb

BIN
Example/bin/Debug_Ubuntu/example.exe

BIN
Example/bin/Debug_Ubuntu/example.exe.mdb

BIN
Example/bin/Debug_Ubuntu/websocket-sharp.dll

BIN
Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb

BIN
Example1/bin/Debug_Ubuntu/example1.exe

BIN
Example1/bin/Debug_Ubuntu/example1.exe.mdb

BIN
Example1/bin/Debug_Ubuntu/websocket-sharp.dll

BIN
Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb

BIN
Example2/bin/Debug_Ubuntu/example2.exe

BIN
Example2/bin/Debug_Ubuntu/example2.exe.mdb

BIN
Example2/bin/Debug_Ubuntu/websocket-sharp.dll

BIN
Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb

BIN
Example3/bin/Debug_Ubuntu/Example3.exe

BIN
Example3/bin/Debug_Ubuntu/Example3.exe.mdb

BIN
Example3/bin/Debug_Ubuntu/websocket-sharp.dll

BIN
Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb

33
websocket-sharp/Server/HttpServer.cs

@ -40,6 +40,7 @@ namespace WebSocketSharp.Server {
#region Fields
private Thread _acceptRequestThread;
private bool _isWindows;
private HttpListener _listener;
private int _port;
private string _rootPath;
@ -62,14 +63,9 @@ namespace WebSocketSharp.Server {
public HttpServer(int port, string wsPath)
{
_listener = new HttpListener();
_port = port;
var prefix = String.Format(
"http{0}://*:{1}/", _port == 443 ? "s" : String.Empty, _port);
_listener.Prefixes.Add(prefix);
_wsPath = wsPath.ToUri();
_wsServer = new WebSocketServer<T>();
configureFromConfigFile();
_port = port;
_wsPath = wsPath.ToUri();
init();
}
#endregion
@ -126,6 +122,23 @@ namespace WebSocketSharp.Server {
_rootPath = ConfigurationManager.AppSettings["RootPath"];
}
private void init()
{
_isWindows = false;
_listener = new HttpListener();
_wsServer = new WebSocketServer<T>();
var os = Environment.OSVersion;
if (os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX)
_isWindows = true;
var prefix = String.Format(
"http{0}://*:{1}/", _port == 443 ? "s" : String.Empty, _port);
_listener.Prefixes.Add(prefix);
configureFromConfigFile();
}
private bool isUpgrade(HttpListenerRequest request, string value)
{
if (!request.Headers.Exists("Upgrade", value))
@ -257,9 +270,7 @@ namespace WebSocketSharp.Server {
public byte[] GetFile(string path)
{
var filePath = _rootPath + path;
var os = Environment.OSVersion;
if (os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX)
if (_isWindows)
filePath = filePath.Replace("/", "\\");
if (File.Exists(filePath))

BIN
websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll

BIN
websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb

BIN
websocket-sharp/websocket-sharp.pidb

Loading…
Cancel
Save