Mercurial > hg > Applications > TreeVNC
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 |
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; |
207 | 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 | 14 public CreateConnectionParam(TreeRFBProto rfb) { |
67 | 15 this.rfb = rfb; |
16 } | |
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 | 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 | 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 | 35 public void sendWhereToConnect(ViewerInterface v) { |
176 | 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 | 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 | 43 } |
130 | 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 | 46 hostName = _hostName; |
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 | 49 notify(); |
130 | 50 } |
51 | |
52 public void setHostName(String hostAndPort) { | |
53 int i = hostAndPort.indexOf(':'); | |
54 if (i>0) { | |
55 portNumber = Integer.parseInt(hostAndPort.substring(i+1)); | |
56 hostName = hostAndPort.substring(0,i); | |
57 } else | |
58 hostName = hostAndPort; | |
176 | 59 // who sets myHostName? |
67 | 60 } |
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 | 66 public int getPort() { |
67 return portNumber; | |
149
1291cf1122ca
panel will not open ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
145
diff
changeset
|
68 } |
176 | 69 |
70 public String getHostName() { | |
71 return hostName; | |
72 } | |
73 | |
67 | 74 } |