Mercurial > hg > Applications > TreeVNC
annotate src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java @ 206:2b3eb4a9492f
MyRfbProto reorganization
author | oc |
---|---|
date | Wed, 02 Jul 2014 17:58:55 +0900 |
parents | 8019a393875a |
children | b31903e5b02d |
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 |
153 | 5 import com.glavsoft.viewer.ViewerInterface; |
130 | 6 import com.glavsoft.viewer.swing.ConnectionParams; |
7 | |
67 | 8 public class CreateConnectionParam { |
9 private String hostName; | |
130 | 10 private int portNumber = ConnectionParams.DEFAULT_VNC_ROOT; |
67 | 11 private MyRfbProto rfb; |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
12 private String myHostName; |
81
f93d0286c2ab
root find multicast send port number now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
80
diff
changeset
|
13 |
67 | 14 public CreateConnectionParam(MyRfbProto rfb) { |
15 this.rfb = rfb; | |
16 } | |
17 | |
142 | 18 public synchronized void findTreeVncRoot() throws InterruptedException { |
144 | 19 rfb.createRootSelectionPanel(this); |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
20 FindRoot getBcast = new FindRoot(rfb.acceptPort,this); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
21 getBcast.findRoot(); |
130 | 22 // wait for RootSelection |
141 | 23 wait(); |
67 | 24 } |
25 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
26 /** |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
27 * 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
|
28 * 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
|
29 * @param v |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
30 */ |
177 | 31 public void sendWhereToConnect(ViewerInterface v) { |
176 | 32 rfb.setConnectionParam(this); |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
33 TreeVncProtocol echo = new TreeVncProtocol(hostName,portNumber); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
34 try { |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
35 echo.whereToConnect(myHostName,rfb.getAcceptPort()); |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
36 } catch (IOException e) { |
176 | 37 System.out.println("cannot connect to root "+e.getMessage()); |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
130
diff
changeset
|
38 } |
67 | 39 } |
130 | 40 |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
41 public synchronized void setHostName(String _hostName, int port, String _myHostName) { |
130 | 42 hostName = _hostName; |
43 portNumber = port; | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
44 myHostName = _myHostName; |
144 | 45 notify(); |
130 | 46 } |
47 | |
48 public void setHostName(String hostAndPort) { | |
49 int i = hostAndPort.indexOf(':'); | |
50 if (i>0) { | |
51 portNumber = Integer.parseInt(hostAndPort.substring(i+1)); | |
52 hostName = hostAndPort.substring(0,i); | |
53 } else | |
54 hostName = hostAndPort; | |
176 | 55 // who sets myHostName? |
67 | 56 } |
57 | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
58 public String getMyHostName() { |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
59 return myHostName; |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
60 } |
149
1291cf1122ca
panel will not open ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
145
diff
changeset
|
61 |
176 | 62 public int getPort() { |
63 return portNumber; | |
149
1291cf1122ca
panel will not open ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
145
diff
changeset
|
64 } |
176 | 65 |
66 public String getHostName() { | |
67 return hostName; | |
68 } | |
69 | |
67 | 70 } |