annotate 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
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;
207
b31903e5b02d rename myRFBProto
oc
parents: 206
diff changeset
11 private TreeRFBProto 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
207
b31903e5b02d rename myRFBProto
oc
parents: 206
diff changeset
14 public CreateConnectionParam(TreeRFBProto rfb) {
67
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
327
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
18 public synchronized void findTreeVncRoot() {
144
1e004d9c599d notify connection panel
oc
parents: 143
diff changeset
19 rfb.createRootSelectionPanel(this);
327
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
20 FindRoot getBcast = new FindRoot(rfb.acceptPort,this);
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
21 getBcast.findRoot();
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
22 // wait for RootSelection
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
23 try {
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
24 wait();
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
25 } catch (InterruptedException e) {
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
26 System.out.println("any thread interrupt when wait for FindRoot " + e.getMessage());
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
27 }
293c35aa902b add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents: 326
diff changeset
28 }
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
30 /**
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
31 * 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
32 * 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
33 * @param v
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
34 */
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
35 public void sendWhereToConnect(ViewerInterface v) {
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
36 rfb.setConnectionParam(this);
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
37 TreeVncProtocol echo = new TreeVncProtocol(hostName,portNumber);
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
38 try {
145
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
39 echo.whereToConnect(myHostName,rfb.getAcceptPort());
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
40 } catch (IOException e) {
326
1d4d5055a288 add error message, add assure stream close.
oc
parents: 207
diff changeset
41 System.out.println("sendWhereToConnect : cannot connect to root "+e.getMessage());
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
42 }
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 }
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
44
145
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
45 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
46 hostName = _hostName;
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
47 portNumber = port;
145
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
48 myHostName = _myHostName;
144
1e004d9c599d notify connection panel
oc
parents: 143
diff changeset
49 notify();
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
50 }
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
51
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
52 public void setHostName(String hostAndPort) {
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
53 int i = hostAndPort.indexOf(':');
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
54 if (i>0) {
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
55 portNumber = Integer.parseInt(hostAndPort.substring(i+1));
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
56 hostName = hostAndPort.substring(0,i);
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
57 } else
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 128
diff changeset
58 hostName = hostAndPort;
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
59 // who sets myHostName?
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 }
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
145
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
62 public String getMyHostName() {
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
63 return myHostName;
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
64 }
149
1291cf1122ca panel will not open ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
65
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
66 public int getPort() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
67 return portNumber;
149
1291cf1122ca panel will not open ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
68 }
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
69
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
70 public String getHostName() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
71 return hostName;
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
72 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 157
diff changeset
73
67
2908e4b95b0a add file
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }