# HG changeset patch # User Ivo Smits # Date 1366303372 -7200 # Node ID 2ecb82eea559b4a91c6314d89b2f4ca6fe6221c1 # Parent 3bfb3ee64362612f69afb5cc6ef3c8e3ed949b12 VNCServer: small change in web client handling diff -r 3bfb3ee64362 -r 2ecb82eea559 VNCServer/VNCServer.cs --- a/VNCServer/VNCServer.cs Wed Apr 17 16:11:09 2013 +0200 +++ b/VNCServer/VNCServer.cs Thu Apr 18 18:42:52 2013 +0200 @@ -253,7 +253,7 @@ return true; } } - public class VNCServer { + public class VNCServer : IHTTPContentProvider { public event EventHandler ClientConnected; public EndPoint LocalEndPoint { get; protected set; } public Boolean Listening { get; protected set; } @@ -297,6 +297,10 @@ } if (Listening) socket.BeginAccept(AcceptCallback, socket); } + void IHTTPContentProvider.ServeRequest(HTTPContext context) { + WebSocketPacketStream stream = new WebSocketPacketStream(context); + ClientAccepted(new VNCServerConnection(stream, context.Socket)); + } protected void ClientAccepted(VNCServerConnection client) { VNCClientConnectedEventArgs clientargs = new VNCClientConnectedEventArgs(this, client, client.RemoteEndPoint); if (ClientConnected != null) ClientConnected(this, clientargs); @@ -313,7 +317,7 @@ public WebVNCServer(int port) : this(new IPEndPoint(IPAddress.Any, port)) { } public WebVNCServer(EndPoint ep) : base(ep) { httpserver = new HTTPServer(); - httpserver.ContentProvider = new HTTPContentProviderFunction(HandleClient); + httpserver.ContentProvider = this; httpserver.ServeFlashPolicyFile = true; } public override void Listen(EndPoint ep) { @@ -322,10 +326,6 @@ public override void Close() { httpserver.Dispose(); } - public void HandleClient(HTTPContext context) { - WebSocketPacketStream stream = new WebSocketPacketStream(context); - ClientAccepted(new VNCServerConnection(stream, context.Socket)); - } } public interface IZLibCompressor { byte[] Compress(Byte[] data, int offset, int count);