7
|
1 package jp.ac.u_ryukyu.alicevnc;
|
|
2
|
|
3 import com.glavsoft.viewer.Viewer;
|
|
4
|
|
5 import alice.codesegment.CodeSegment;
|
|
6 import alice.datasegment.CommandType;
|
|
7 import alice.datasegment.Receiver;
|
|
8
|
20
|
9 public class NegotiateVNCServer extends CodeSegment {
|
7
|
10 private Receiver info = ids.create(CommandType.PEEK);
|
20
|
11 private Receiver info1 = ids.create(CommandType.PEEK);
|
7
|
12
|
20
|
13 public NegotiateVNCServer(){
|
|
14 info.setKey("host");
|
|
15 info1.setKey("AliceVNCConfig");
|
7
|
16 }
|
22
|
17
|
20
|
18 @Override
|
7
|
19 public void run() {
|
22
|
20
|
20
|
21 AliceVNCConfig conf = info1.asClass(AliceVNCConfig.class);
|
|
22 String hostname = info.asString();
|
22
|
23
|
20
|
24 if ("node0".equals(hostname)) {
|
|
25 // root node connect to vnc Server first time.
|
|
26 String[] args = {"localhost"};
|
22
|
27
|
|
28 // negotiate VNCServer by Viewer
|
20
|
29 Viewer.main(args);
|
|
30 new ReceiveServerInitMessage();
|
15
|
31 } else {
|
20
|
32 new ReceiveServerInitMessage("parent");
|
22
|
33 if (conf.getProxyFlag()){
|
|
34 new SendChangeRequest();
|
|
35
|
20
|
36 }
|
15
|
37 }
|
23
|
38 new ReceiveChangeRequest();
|
|
39 new SendChangeRequest();
|
7
|
40 }
|
|
41
|
|
42 }
|