Mercurial > hg > Applications > TreeVNC
annotate src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 143:4547543ca73c
findRootReply
author | oc |
---|---|
date | Thu, 12 Jun 2014 19:21:38 +0900 |
parents | d2af9edb1803 |
children | 1e004d9c599d |
rev | line source |
---|---|
67 | 1 package jp.ac.u_ryukyu.treevnc; |
2 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
3 import java.io.IOException; |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
4 |
67 | 5 import com.glavsoft.viewer.ViewerImpl; |
130 | 6 import com.glavsoft.viewer.swing.ConnectionParams; |
7 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
8 import jp.ac.u_ryukyu.treevnc.client.FindRoot; |
125 | 9 import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol; |
81
f93d0286c2ab
root find multicast send port number now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
80
diff
changeset
|
10 |
67 | 11 public class CreateConnectionParam { |
12 private String hostName; | |
130 | 13 private int portNumber = ConnectionParams.DEFAULT_VNC_ROOT; |
67 | 14 private MyRfbProto rfb; |
81
f93d0286c2ab
root find multicast send port number now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
80
diff
changeset
|
15 |
67 | 16 public CreateConnectionParam(MyRfbProto rfb) { |
17 this.rfb = rfb; | |
18 } | |
19 | |
142 | 20 public synchronized void findTreeVncRoot() throws InterruptedException { |
143 | 21 rfb.createRootSelectionPanel(); |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
22 FindRoot getBcast = new FindRoot(rfb.acceptPort,this); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
23 getBcast.findRoot(); |
130 | 24 // wait for RootSelection |
141 | 25 wait(); |
67 | 26 } |
27 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
28 /** |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
29 * To find parent, send WHERE_TO_CONNECT command to the TreeVNC root |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
30 * Incoming CONNECT_TO message is handled in MyRFBProto |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
31 * @param v |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
32 */ |
67 | 33 public void createConnectionParam(ViewerImpl v) { |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
34 TreeVncProtocol echo = new TreeVncProtocol(hostName,portNumber); |
67 | 35 rfb.setEcho(echo); |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
36 try { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
37 echo.whereToConnect(rfb.getMyAddress(),rfb.getAcceptPort()); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
38 } catch (IOException e) { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
39 // cannot send where to connect |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
40 } |
67 | 41 } |
130 | 42 |
128 | 43 public void runAcceptThread() { |
142 | 44 rfb.selectPort(ConnectionParams.DEFAULT_VNC_ROOT); |
45 AcceptThread acceptThread = new AcceptThread(rfb, rfb.getAcceptPort()); | |
46 portNumber = rfb.getAcceptPort(); | |
47 Thread accThread = new Thread(acceptThread); | |
67 | 48 accThread.start(); |
49 } | |
130 | 50 |
51 public void setHostName(String _hostName, int port) { | |
52 hostName = _hostName; | |
53 portNumber = port; | |
54 } | |
55 | |
56 public void setHostName(String hostAndPort) { | |
57 int i = hostAndPort.indexOf(':'); | |
58 if (i>0) { | |
59 portNumber = Integer.parseInt(hostAndPort.substring(i+1)); | |
60 hostName = hostAndPort.substring(0,i); | |
61 } else | |
62 hostName = hostAndPort; | |
67 | 63 } |
64 | |
65 } |