diff src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java @ 187:b62a16548800

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 24 Jun 2014 09:35:45 +0900
parents f76ee760c2d2
children f176bffcdc4a
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Tue Jun 24 00:48:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Tue Jun 24 09:35:45 2014 +0900
@@ -48,7 +48,7 @@
     private Inflater inflater = new Inflater();
     private Deflater deflater = new Deflater();
     ViewerInterface viewer;
-	private short id;
+	private short id;  // my tree node id ( = 0 in root )
     private boolean leader;
     public TreeManagement treeManager;
     private TreeVncCommandChannelListener acceptThread;
@@ -57,6 +57,7 @@
     private CreateConnectionParam cp;
     private boolean hasViewer = false;
     private boolean reconnecting;
+    private short reconnectingId;  // Change Server Request to id's node VNC server
 
 
 	public MyRfbProto() {
@@ -347,11 +348,12 @@
 		
 	}
 
-	public void setReadyReconnect(boolean ready) {
+	public synchronized void setReadyReconnect(boolean ready) {
 	    if (reconnecting) {
-	        sendDesktopSizeChange(id);
+	        sendDesktopSizeChange(reconnectingId);
 	        reconnecting = false;
-	    } else {
+	    } 
+	    if (reconnectingId!=0) {
 	        readyReconnect = ready;
 	        if (ready) {
 	            notifyAll();
@@ -360,9 +362,11 @@
 	}	
 
 	public synchronized void waitForReady() throws InterruptedException {
-		while (!readyReconnect) {
-			wait();
-		}
+	    if (reconnectingId!=0) {
+	        while (!readyReconnect) {
+	            wait();
+	        }
+	    }
 	}
 
 
@@ -620,8 +624,11 @@
     	// stop reader stop
         stopReceiverTask();
     	vncProxyService.inhelitClients(vncProxyService, hostName);
+        // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary 
     	reconnecting = true;
-    	// after connecting VNC server, rfb send SEND_INIT_DATA command 
+    	if (reconnectingId!=0) {
+    	    waitForReady();
+    	}
     }
 
     /**