changeset 70:affdcbdc90ea

modify CreateCanva.java. implement ZRLEE.
author e085711
date Sun, 07 Aug 2011 13:40:56 +0900
parents 1f05b73b15df
children f6cb1edc2036
files src/myVncClient/CuiMyVncClient.java src/myVncClient/MyVncClient.java src/myVncClient/VncCanvas.java
diffstat 3 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncClient/CuiMyVncClient.java	Sun Aug 07 04:22:07 2011 +0900
+++ b/src/myVncClient/CuiMyVncClient.java	Sun Aug 07 13:40:56 2011 +0900
@@ -96,12 +96,13 @@
 	//
 
 	public void init(EchoClient value) {
+
 		Random rnd = new Random();
 		long ran = rnd.nextInt(5000);
 		try {
 			Thread.sleep(ran);
-		} catch (InterruptedException e1) {
-			e1.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
 		}
 		// readParameters();
 
@@ -142,18 +143,19 @@
 		try {
 			if (first) {
 				connectAndAuthenticate();
+				accThread = new Thread(new AcceptThread(rfb, 5999));
+				accThread.start();
 				first = false;
 			}else {
 				reConnectAndAuthenticate();
 			}
-			accThread = new Thread(new AcceptThread(rfb, 5999));
-			accThread.start();
 			doProtocolInitialisation();
 
 			vc = new CuiVncCanvas(this, 0, 0);
 			vc.updateFramebufferSize();
 
 		} catch (IOException e) {
+			
 			System.out.println("Socket error");
 			// parent no find
 			Random rnd = new Random();
@@ -194,7 +196,6 @@
 				}
 				counter++;
 			}
-
 			// System.exit(0);
 		}catch (Exception e) {
 			System.out.println(e);
@@ -328,8 +329,8 @@
 		}
 	}
 
-	
-	
+
+
 	void reConnectAndAuthenticate() throws Exception {
 		showConnectionStatus("Initializing...");
 
--- a/src/myVncClient/MyVncClient.java	Sun Aug 07 04:22:07 2011 +0900
+++ b/src/myVncClient/MyVncClient.java	Sun Aug 07 13:40:56 2011 +0900
@@ -107,14 +107,15 @@
 
 		try {
 
+			connectAndAuthenticate();
 			if (first) {
-				connectAndAuthenticate();
+				accThread = new Thread(new AcceptThread(rfb, 5999));
+				accThread.start();
 				first = false;
 			}else {
+				System.out.println("reConnectAndAuthenticate() ");
 				reConnectAndAuthenticate();
 			}
-			accThread = new Thread(new AcceptThread(rfb, 5999));
-			accThread.start();
 
 			doProtocolInitialisation();
 
@@ -124,6 +125,12 @@
 			// vc.drawFirstImage();
 
 		} catch (IOException e) {
+			try{
+				rfb.sock.close();
+
+			}catch(IOException e2){
+				e2.printStackTrace();
+			}
 			System.out.println("Socket error");
 			// parent no find
 			Random rnd = new Random();
@@ -218,7 +225,8 @@
 			fatalError("Network error: could not connect to server: " + host
 					+ ":" + port, e);
 		} catch (EOFException e) {
-
+			System.out.println("EOFException : rfb.sock.close()");
+			
 			vncFrame.setVisible(false);
 			vncFrame.dispose();
 			// num4
--- a/src/myVncClient/VncCanvas.java	Sun Aug 07 04:22:07 2011 +0900
+++ b/src/myVncClient/VncCanvas.java	Sun Aug 07 13:40:56 2011 +0900
@@ -478,6 +478,10 @@
 						statNumRectsZRLE++;
 						handleZRLERect(rx, ry, rw, rh);
 						break;
+					case RfbProto.EncodingZRLEE:
+						statNumRectsZRLE++;
+						handleZRLERect(rx, ry, rw, rh);
+						break;
 					case RfbProto.EncodingZlib:
 						handleZlibRect(rx, ry, rw, rh);
 						break;
@@ -876,7 +880,8 @@
 	//
 
 	void handleZRLERect(int x, int y, int w, int h) throws Exception {
-
+		if (rfb.updateRectEncoding==RfbProto.EncodingZRLEE) zrleInStream = null;
+		
 		if (zrleInStream == null)
 			zrleInStream = new ZlibInStream();