changeset 29:2ecb82eea559

VNCServer: small change in web client handling
author Ivo Smits <Ivo@UCIS.nl>
date Thu, 18 Apr 2013 18:42:52 +0200
parents 3bfb3ee64362
children 24e918d2ac18
files VNCServer/VNCServer.cs
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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<VNCClientConnectedEventArgs> 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);