diff src/myVncProxy/MyRfbProto.java @ 65:5fca2bb52dc7

create checkMillis
author e085711
date Fri, 22 Jul 2011 03:21:56 +0900
parents 7795e2b5d3ef
children 7632606406cb
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);
 				}