diff src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 134:128cce60c43c

where to connect command
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 07 Jun 2014 15:57:03 +0900
parents 1f6bfaa3281b
children 8798f36f732b
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java	Sat Jun 07 12:54:44 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java	Sat Jun 07 15:57:03 2014 +0900
@@ -1,10 +1,12 @@
 package jp.ac.u_ryukyu.treevnc;
 
+import java.io.IOException;
+
 import com.glavsoft.viewer.ViewerImpl;
 import com.glavsoft.viewer.swing.ConnectionParams;
 
+import jp.ac.u_ryukyu.treevnc.client.FindRoot;
 import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol;
-import jp.ac.u_ryukyu.treevnc.client.GetHostClient;
 
 public class CreateConnectionParam {
 	private String hostName;
@@ -16,18 +18,25 @@
 	}
 
 	public void findTreeVncRoot() throws InterruptedException {
-		GetHostClient getBcast = new GetHostClient(rfb.acceptPort,this);
-		getBcast.getHost();
+		FindRoot getBcast = new FindRoot(rfb.acceptPort,this);
+		getBcast.findRoot();
 		// wait for RootSelection
         wait();
 	}
 
+	/**
+	 * To find parent, send WHERE_TO_CONNECT command to the TreeVNC root
+	 * Incoming CONNECT_TO message is handled in MyRFBProto
+	 * @param v
+	 */
 	public void createConnectionParam(ViewerImpl v) {
-		TreeVncProtocol echo = new TreeVncProtocol(hostName, 9999); 
+		TreeVncProtocol echo = new TreeVncProtocol(hostName,portNumber);
 		rfb.setEcho(echo);
-		rfb.setProxyAddr(hostName);
-		echo.getParentName();
-		v.setConnectionParam(echo.getParentsAddress(), portNumber);
+		try {
+            echo.whereToConnect(rfb.getMyAddress(),rfb.getAcceptPort());
+        } catch (IOException e) {
+            // cannot send where to connect
+        }
 	}
 	
 	public void runAcceptThread() {