Mercurial > hg > Members > riono > TreeVNC_ja_comment
view src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 327:293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
author | oc |
---|---|
date | Sun, 01 Feb 2015 17:34:09 +0900 |
parents | 1d4d5055a288 |
children | 230038d5127d |
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; } 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; } }