changeset 43:6687aa9dd55e

add flag for screen change in ReciverTask.java.
author one
date Tue, 06 Nov 2012 15:36:46 +0900
parents fe38611c4b2b
children d4663dfd91ae
files src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java
diffstat 7 files changed, 44 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java	Tue Nov 06 15:36:46 2012 +0900
@@ -119,7 +119,7 @@
 				}
 			} catch (TransportException e) {
 				logger.severe("Close session: " + e.getMessage());
-				if(rfb instanceof MyRfbProtoClient) {
+				if(rfb instanceof MyRfbProtoClient && !(rfb.getTerminationType())) {
 					System.out.println("task stop");
 					int counter = 0;
 					EchoClient echo = rfb.getEcho();
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Tue Nov 06 15:36:46 2012 +0900
@@ -329,4 +329,14 @@
 	public EchoClient getEcho() {
 		return echo;
 	}
+
+
+	public void setTerminationType(boolean setType) {
+		/*nop*/
+	}
+
+	public boolean getTerminationType() {
+		/*nop*/
+		return true;
+	}
 }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java	Tue Nov 06 15:36:46 2012 +0900
@@ -24,11 +24,10 @@
 		this.echoPort = echoPort;
 		this.name = name;
 	}
-	
 
 	public void openport() {
 		try {
-			//if(echoSocket==null)
+			// if(echoSocket==null)
 			echoSocket = new Socket(name, echoPort);
 			echoSocket.setReuseAddress(true);
 			os = new DataOutputStream(echoSocket.getOutputStream());
@@ -66,7 +65,7 @@
 			} catch (IOException e) {
 				System.err.println("IOException: " + e);
 			}
-			waitReply = new WaitReply(treeNum,this);
+			waitReply = new WaitReply(treeNum, this);
 			waitReply.start();
 		}
 		return this;
@@ -169,12 +168,15 @@
 	}
 
 	void reConnectionMain(Socket echoSocket) {
-		try {
-			client.close();
-			client.setSocket(createSocketForClient(echoSocket));
-			client.run();
-		} catch (IOException e) {
-			e.printStackTrace();
+		while (true) {
+			try {
+				client.close();
+				client.setSocket(createSocketForClient(echoSocket));
+				client.run();
+				break;
+			} catch (IOException e) {
+				continue;
+			}
 		}
 	}
 
@@ -211,7 +213,7 @@
 			System.err.println("IOException: " + e);
 		}
 	}
-	
+
 	public void getParentName() {
 		if (clientSocket == null) {
 			// echo = new EchoClient(pHost, this);
@@ -231,12 +233,12 @@
 				soc.getInputStream()));
 		String tempParentAddress = is.readLine();
 		parentNum = is.readLine();
-		if("reconnection".equals(tempParentAddress)) {
+		if ("reconnection".equals(tempParentAddress)) {
 			System.out.println("-----------------into function \n" + parentNum);
-			return new Socket(parentAddress,Integer.parseInt(parentNum));
-		} 
+			return new Socket(parentAddress, Integer.parseInt(parentNum));
+		}
 		treeNum = is.readLine();
 		leaderFlag = is.readLine();
-		return new Socket(tempParentAddress,5999);
+		return new Socket(tempParentAddress, 5999);
 	}
 }
\ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java	Tue Nov 06 15:36:46 2012 +0900
@@ -36,6 +36,7 @@
 	boolean proxyFlag = false;
 	int serverMajor, serverMinor;
 	int clientMajor, clientMinor;
+	private boolean normalTermination;
 
 	private Inflater inflater = new Inflater();
 	private Deflater deflater = new Deflater();
@@ -362,5 +363,15 @@
 		// But we have do inflation for all input data, so we have to do it
 		// here.
 	}
+	
+	@Override
+	public void setTerminationType(boolean setType) {
+		normalTermination = setType;
+	}
+	
+	@Override
+	public boolean getTerminationType() {
+		return normalTermination;
+	}
 
 }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java	Tue Nov 06 15:36:46 2012 +0900
@@ -30,6 +30,7 @@
 				echoServer = new ServerSocket(10001);
 				clientSocket = echoServer.accept();
 				if (clientSocket != null) {
+					echo.client.setTeminationType(true);
 					echo.client.stopTask();
 					echo.client.close();
 					passflag = true;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Tue Nov 06 15:36:46 2012 +0900
@@ -160,9 +160,9 @@
 				updateFrameTitle();
 				containerFrame.dispose();
 				containerFrame = null;
-				workingProtocol.startNormalHandling(this, surface, clipboardController,rfb);
 				if(tempWorkingProtocol!=null)
 					tempWorkingProtocol.cleanUpSession();
+				workingProtocol.startNormalHandling(this, surface, clipboardController,rfb);
 				// rfb.setInitData(workingProtocol.getInitData()); too early
 				// workingProtocol.startNormalHandling(this, surface, clipboardController);
 				tryAgain = false;
@@ -201,11 +201,6 @@
 		thread = new Thread(getCast);		
 		thread.start();
 	}
-	
-	public void start_threads() {
-		//rfbThread.start();
-		//rfb.requestThreadStart();
-	}
 
 	public void proxyStart(String[] argv) {
 		String[] mainArgs = argv;
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Tue Nov 06 15:36:46 2012 +0900
@@ -687,4 +687,8 @@
 	public void stopTask() {
 		workingProtocol.cleanUpSession();
 	}
+	
+	public void setTeminationType(boolean setType) {
+		rfb.setTerminationType(true);
+	}
 }