Mercurial > hg > Applications > TreeVNC
view src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 126:775ce6a14f89
find root.
author | oc |
---|---|
date | Fri, 06 Jun 2014 19:17:32 +0900 |
parents | 32c6563492f3 |
children | cc1fcdc7657c |
line wrap: on
line source
package jp.ac.u_ryukyu.treevnc; import java.util.logging.Logger; import com.glavsoft.viewer.ViewerImpl; import com.glavsoft.viewer.swing.ConnectionParams; import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol; import jp.ac.u_ryukyu.treevnc.client.GetHostClient; public class CreateConnectionParam { private String hostName; private int portNumber; private MyRfbProto rfb; private final Logger logger; public CreateConnectionParam(MyRfbProto rfb) { this.rfb = rfb; logger = Logger.getLogger(getClass().getName()); } public void findTreeVncRoot() { GetHostClient getBcast = new GetHostClient(ConnectionParams.DEFAULT_VNC_ROOT_FINDER); getBcast.getHost(); portNumber = 0; do { try { Thread runBcast = new Thread(getBcast, "TreeVNC-root-finder"); runBcast.start(); hostName = getBcast.textAddress(); // wait for root reply to our broadcast portNumber = Integer.parseInt(getBcast.textPort()); } catch (Exception e) { logger.info("can't get parent address or port"); } getBcast.interrupt(); } while ( portNumber == 0); } public void createConnectionParam(ViewerImpl v) { TreeVncProtocol echo = new TreeVncProtocol(hostName, 9999); rfb.setEcho(echo); rfb.setProxyAddr(hostName); echo.getParentName(); v.setConnectionParam(echo.getParentsAddress(), portNumber); runAcceptThread(); } private void runAcceptThread() { Thread accThread = new Thread(new AcceptThread(rfb, portNumber)); accThread.start(); } public void setHostName(String _hostName) { hostName = _hostName; portNumber = 5999; } }