Mercurial > hg > Applications > TreeVNC
view src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 329:230038d5127d
change reconnect new node instead of lost child node.
author | oc |
---|---|
date | Mon, 02 Feb 2015 20:18:53 +0900 |
parents | 293c35aa902b |
children | 42fcc9419498 |
line wrap: on
line source
package jp.ac.u_ryukyu.treevnc; import java.io.IOException; import com.glavsoft.viewer.ViewerInterface; import com.glavsoft.viewer.swing.ConnectionParams; public class CreateConnectionParam { private String hostName; private int portNumber = ConnectionParams.DEFAULT_VNC_ROOT; private TreeRFBProto rfb; private String myHostName; public CreateConnectionParam(TreeRFBProto rfb) { this.rfb = rfb; rfb.setConnectionParam(this); } public synchronized void findTreeVncRoot() { rfb.createRootSelectionPanel(this); FindRoot getBcast = new FindRoot(rfb.acceptPort,this); getBcast.findRoot(); // wait for RootSelection try { wait(); } catch (InterruptedException e) { System.out.println("any thread interrupt when wait for FindRoot " + e.getMessage()); } } /** * To find parent, send WHERE_TO_CONNECT command to the TreeVNC root * Incoming CONNECT_TO message is handled in MyRFBProto * @param v */ public void sendWhereToConnect(ViewerInterface v) { rfb.setConnectionParam(this); TreeVncProtocol echo = new TreeVncProtocol(hostName,portNumber); try { echo.whereToConnect(myHostName,rfb.getAcceptPort()); } catch (IOException e) { System.out.println("sendWhereToConnect : cannot connect to root "+e.getMessage()); } } public synchronized void setHostName(String _hostName, int port, String _myHostName) { hostName = _hostName; portNumber = port; myHostName = _myHostName; notify(); } public void setHostName(String hostAndPort) { int i = hostAndPort.indexOf(':'); if (i>0) { portNumber = Integer.parseInt(hostAndPort.substring(i+1)); hostName = hostAndPort.substring(0,i); } else hostName = hostAndPort; // who sets myHostName? } public String getMyHostName() { return myHostName; } public int getPort() { return portNumber; } public String getHostName() { return hostName; } }