Mercurial > hg > trac > TreeVNC > TreeVNC
view src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 138:c3761c896607 default tip
minor fix
author | oc |
---|---|
date | Tue, 10 Jun 2014 13:15:59 +0900 |
parents | 128cce60c43c |
children |
line wrap: on
line source
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; public class CreateConnectionParam { private String hostName; private int portNumber = ConnectionParams.DEFAULT_VNC_ROOT; private MyRfbProto rfb; public CreateConnectionParam(MyRfbProto rfb) { this.rfb = rfb; } public void findTreeVncRoot() throws InterruptedException { 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,portNumber); rfb.setEcho(echo); try { echo.whereToConnect(rfb.getMyAddress(),rfb.getAcceptPort()); } catch (IOException e) { // cannot send where to connect } } public void runAcceptThread() { Thread accThread = new Thread(new AcceptThread(rfb, portNumber)); accThread.start(); } public void setHostName(String _hostName, int port) { hostName = _hostName; portNumber = port; } 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; } }