changeset 65:5fca2bb52dc7

create checkMillis
author e085711
date Fri, 22 Jul 2011 03:21:56 +0900
parents 4864a7d1df00
children 7632606406cb
files src/myVncProxy/MyRfbProto.java src/myVncProxy/ProxyVncCanvas.java src/myVncProxy/VncProxyService.java src/myVncProxy/acceptThread.java
diffstat 4 files changed, 65 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java	Tue Jul 12 13:47:32 2011 +0900
+++ b/src/myVncProxy/MyRfbProto.java	Fri Jul 22 03:21:56 2011 +0900
@@ -24,8 +24,13 @@
 import java.io.OutputStream;
 
 class MyRfbProto extends RfbProto {
-
 	final static String versionMsg_3_998 = "RFB 003.998\n";
+	/**
+	 * CheckMillis is one of new msgType for RFB 3.998. 
+	 */
+	final static int CheckMillis = 4;
+	boolean printStatusFlag = false;
+	long startCheckTime;
 
 	private int messageType;
 	private int rectangles;
@@ -339,11 +344,13 @@
 		}
 		return dataLen;
 	}
+	
 	void readSendData(int dataLen) throws IOException {
 		byte buffer[] = new byte[dataLen];
 		readFully(buffer);
 		multicastqueue.put(buffer);
 		reset();
+
 /*
 		for (Socket cli : cliList) {
 			try {
@@ -414,12 +421,12 @@
 		BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(pngBytes));
 		return bimg;
 	}
-
+/*
 	void readPngData() throws IOException {
 		pngBytes = new byte[is.available()];
 		readFully(pngBytes);
 	}
-
+*/
 	void printFramebufferUpdate() {
 
 		System.out.println("messageType=" + messageType);
@@ -433,6 +440,42 @@
 		default:
 		}
 	}
+	
+	void readCheckMillis() throws IOException {
+		byte[] b = new byte[4];
+		readFully(b);
+	}
+	
+	void startCheckMills() {
+		byte[] b = new byte[4];
+		b = castIntByte(4);
+		startCheckTime = System.currentTimeMillis(); 
+		multicastqueue.put(b);
+	}
+
+	void endCheckMills() {
+		long accTime = System.currentTimeMillis();
+		long time = accTime - startCheckTime;
+		System.out.println("checkMillis: " + time);
+	}
+
+	void printStatus() {
+		System.out.println();
+	}
+
+	synchronized void changeStatusFlag() {
+		printStatusFlag = true;
+	}
+
+	void printMills() {
+		if(printStatusFlag) {
+
+			changeStatusFlag();
+		} else {
+			changeStatusFlag();
+		}
+	}
+	
 
 	void newClient(acceptThread acceptThread, final Socket newCli,
 			final OutputStream os, final InputStream is) throws IOException {
@@ -443,7 +486,9 @@
 		Runnable sender = new Runnable() {
 			public void run() {
 				try {
-					// 初期接続確立の部分
+					/**
+					 *  initial connection of RFB protocol
+					 */
 					sendRfbVersion(os);
 					readVersionMsg(is);
 					sendSecurityType(os);
@@ -457,8 +502,9 @@
 						os.write(b, 0, b.length);
 					}
 				} catch (IOException e) {
-					//接続が切れた処理
-					//lockしないと駄目
+					/**
+					 * if socket closed
+					 */
 					//					cliList.remove(newCli);
 				}
 
--- a/src/myVncProxy/ProxyVncCanvas.java	Tue Jul 12 13:47:32 2011 +0900
+++ b/src/myVncProxy/ProxyVncCanvas.java	Fri Jul 22 03:21:56 2011 +0900
@@ -360,18 +360,14 @@
 		// main dispatch loop
 		//
 
-
-		
-		
 		long count = 0;
 		while (true) {
 //			System.out.println("\ncount=" + count);
 
 			count++;
 			
-			/*
+			/**
 			 *  read Data from parents and send Data to Client.
-			 *  
 			 */
 			rfb.sendDataToClient();		
 
@@ -382,6 +378,10 @@
 
 			// Process the message depending on its type.
 			switch (msgType) {
+			case MyRfbProto.CheckMillis:
+				rfb.readCheckMillis();
+				
+				break;
 			case RfbProto.FramebufferUpdate:
 
 				if (statNumUpdates == viewer.debugStatsExcludeUpdates
@@ -504,7 +504,7 @@
 					setPixelFormat();
 					fullUpdateNeeded = true;
 				}
-*/				
+*/
 				
 				// Request framebuffer update if needed.
 				int w = rfb.framebufferWidth;
--- a/src/myVncProxy/VncProxyService.java	Tue Jul 12 13:47:32 2011 +0900
+++ b/src/myVncProxy/VncProxyService.java	Fri Jul 22 03:21:56 2011 +0900
@@ -15,7 +15,6 @@
 
 		v.init();
 		v.start_threads();
-		
 	}
 	
 	String[] mainArgs;
@@ -293,8 +292,8 @@
 		System.out.println("Desktop size is " + rfb.framebufferWidth + " x "
 				+ rfb.framebufferHeight);
 
-		setEncodings();
-
+//		setEncodings();
+		autoSelectEncodings();
 		//showConnectionStatus(null);
 	}
 
--- a/src/myVncProxy/acceptThread.java	Tue Jul 12 13:47:32 2011 +0900
+++ b/src/myVncProxy/acceptThread.java	Fri Jul 22 03:21:56 2011 +0900
@@ -1,5 +1,5 @@
 package myVncProxy;
-import java.net.ServerSocket;
+
 import java.net.Socket;
 import java.io.IOException;
 import java.io.InputStream;
@@ -9,23 +9,23 @@
 	MyRfbProto rfb;
 	byte[] imageBytes;
 
-	acceptThread(MyRfbProto _rfb ) {
+	acceptThread(MyRfbProto _rfb) {
 		rfb = _rfb;
 	}
+
 	public void run() {
 		rfb.selectPort();
 		while (true) {
 			try {
 				Socket newCli = rfb.accept();
-				
+
 				OutputStream os = newCli.getOutputStream();
 				InputStream is = newCli.getInputStream();
 				rfb.newClient(this, newCli, os, is);
-				} catch (IOException e) {
+			} catch (IOException e) {
 				e.printStackTrace();
 				System.out.println(e);
 			}
 		}
 	}
 }
-