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