changeset 61:626cf8cc002c

modify MyRfbProto.java
author e085711
date Sat, 09 Jul 2011 14:08:28 +0900
parents 3ccedb44aaa0
children 7795e2b5d3ef
files src/myVncProxy/MyRfbProto.java src/myVncProxy/ProxyVncCanvas.java src/myVncProxy/VncCanvas.java
diffstat 3 files changed, 43 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java	Sat Jul 09 11:45:36 2011 +0900
+++ b/src/myVncProxy/MyRfbProto.java	Sat Jul 09 14:08:28 2011 +0900
@@ -35,7 +35,6 @@
 	private int rectH;
 	private int encoding;
 	private int zLen;
-	private int dataLen;
 
 	private ServerSocket servSock;
 	private int acceptPort;
@@ -56,7 +55,7 @@
 		cliList = new LinkedList<Socket>();
 		cliListTmp = new LinkedList<Socket>();
 		createBimgFlag = false;
-		sendThreads = new LinkedList<Thread>();
+		//		sendThreads = new LinkedList<Thread>();
 		// executor = Executors.newCachedThreadPool();
 		// executor = Executors.newSingleThreadExecutor();
 	}
@@ -66,7 +65,7 @@
 		cliList = new LinkedList<Socket>();
 		cliListTmp = new LinkedList<Socket>();
 		createBimgFlag = false;
-		sendThreads = new LinkedList<Thread>();
+		//		sendThreads = new LinkedList<Thread>();
 		// executor = Executors.newCachedThreadPool();
 		// executor = Executors.newSingleThreadExecutor();
 	}
@@ -307,25 +306,7 @@
 		sendData(buffer);
 	}
 
-	void readSendData() throws IOException {
-		byte buffer[] = new byte[dataLen];
-		readFully(buffer);
-		reset();
-
-		for (Socket cli : cliList) {
-			try {
-				OutputStream out = cli.getOutputStream();
-				executor.execute(new SendThread(out, buffer));
-			} catch (IOException e) {
-				// if client socket closed
-				cliListTmp.remove(cli);
-			} catch (Exception e) {
-
-			}
-
-		}
-	}
-
+	
 	void regiFramebufferUpdate() throws IOException {
 		mark(20);
 		messageType = readU8();
@@ -341,7 +322,8 @@
 		reset();
 	}
 
-	void checkAndMark() throws IOException {
+	int checkAndMark() throws IOException {
+		int dataLen;
 		switch (encoding) {
 		case RfbProto.EncodingRaw:
 			dataLen = rectW * rectH * 4 + 16;
@@ -352,8 +334,35 @@
 			mark(dataLen);
 			break;
 		default:
+			dataLen = 1000000;
 			mark(1000000);
 		}
+		return dataLen;
+	}
+	void readSendData(int dataLen) throws IOException {
+		byte buffer[] = new byte[dataLen];
+		readFully(buffer);
+		multicastqueue.put(buffer);
+		reset();
+/*
+		for (Socket cli : cliList) {
+			try {
+				OutputStream out = cli.getOutputStream();
+				executor.execute(new SendThread(out, buffer));
+			} catch (IOException e) {
+				// if client socket closed
+				cliListTmp.remove(cli);
+			} catch (Exception e) {
+
+			}
+
+		}
+*/
+	}
+	void sendDataToClient() throws IOException {
+		regiFramebufferUpdate();
+		int dataLen = checkAndMark();
+		readSendData(dataLen);		
 	}
 
 	BufferedImage createBufferedImage(Image img) {
--- a/src/myVncProxy/ProxyVncCanvas.java	Sat Jul 09 11:45:36 2011 +0900
+++ b/src/myVncProxy/ProxyVncCanvas.java	Sat Jul 09 14:08:28 2011 +0900
@@ -369,11 +369,11 @@
 
 			count++;
 			
-			rfb.regiFramebufferUpdate();
-			rfb.checkAndMark();
-//			rfb.printFramebufferUpdate();
-			rfb.readSendData();
-
+			/*
+			 *  read Data from parents and send Data to Client.
+			 *  
+			 */
+			rfb.sendDataToClient();		
 
 			int bufSize = (int)rfb.getNumBytesRead();
 			
--- a/src/myVncProxy/VncCanvas.java	Sat Jul 09 11:45:36 2011 +0900
+++ b/src/myVncProxy/VncCanvas.java	Sat Jul 09 14:08:28 2011 +0900
@@ -395,10 +395,12 @@
 //			System.out.println("\ncount=" + count);
 			count++;
 			
-			rfb.regiFramebufferUpdate();
-//			rfb.printFramebufferUpdate();
-			rfb.checkAndMark();
-			rfb.readSendData();
+			
+			/*
+			 *  read Data from parents and send Data to Client.
+			 *  
+			 */
+			rfb.sendDataToClient();		
 			
 //			rfb.printNumBytesRead();
 			long bufSize = rfb.getNumBytesRead();