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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package jp.ac.u_ryukyu.treevnc;
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
e68dfd1972ac fix bad names.
oc
parents: 149
diff changeset
5 import com.glavsoft.viewer.ViewerInterface;
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
6 import com.glavsoft.viewer.swing.ConnectionParams;
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
7
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 public class CreateConnectionParam {
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 private String hostName;
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
10 private int portNumber = ConnectionParams.DEFAULT_VNC_ROOT;
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 public CreateConnectionParam(MyRfbProto rfb) {
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 this.rfb = rfb;
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 }
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
142
d2af9edb1803 fix selectRfbSelectPort.
oc
parents: 141
diff changeset
18 public synchronized void findTreeVncRoot() throws InterruptedException {
144
1e004d9c599d notify connection panel
oc
parents: 143
diff changeset
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
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
22 // wait for RootSelection
141
1fa40e04f099 minor fix
oc
parents: 139
diff changeset
23 wait();
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 }
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
31 public void sendWhereToConnect(ViewerInterface v) {
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
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
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
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
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 }
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
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
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
42 hostName = _hostName;
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
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
1e004d9c599d notify connection panel
oc
parents: 143
diff changeset
45 notify();
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
46 }
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
47
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
48 public void setHostName(String hostAndPort) {
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
49 int i = hostAndPort.indexOf(':');
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
50 if (i>0) {
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
51 portNumber = Integer.parseInt(hostAndPort.substring(i+1));
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
52 hostName = hostAndPort.substring(0,i);
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
53 } else
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
54 hostName = hostAndPort;
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
55 // who sets myHostName?
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 }
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
62 public int getPort() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
63 return portNumber;
149
1291cf1122ca panel will not open ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
64 }
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
65
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
66 public String getHostName() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
67 return hostName;
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
68 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
69
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 }