Mercurial > hg > Members > riono > TreeVNC_ja_comment
annotate src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java @ 145:649794dfb9d5
add my hostname to handle multiple network
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Jun 2014 22:01:05 +0900 |
parents | 1e004d9c599d |
children | 5be1d92e7835 |
rev | line source |
---|---|
12 | 1 package jp.ac.u_ryukyu.treevnc.client; |
3 | 2 |
3 import java.io.IOException; | |
4 import java.io.OutputStream; | |
5 | |
144 | 6 import jp.ac.u_ryukyu.treevnc.CreateConnectionParam; |
32 | 7 import jp.ac.u_ryukyu.treevnc.MyRfbProto; |
12 | 8 |
3 | 9 import com.glavsoft.exceptions.TransportException; |
20
98519d16a8c3
getInitData from ProtocolContext
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
10 import com.glavsoft.rfb.protocol.ProtocolContext; |
3 | 11 import com.glavsoft.transport.Reader; |
12 | |
28 | 13 public class MyRfbProtoClient extends MyRfbProto { |
3 | 14 private Reader reader; |
20
98519d16a8c3
getInitData from ProtocolContext
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
15 private ProtocolContext context; |
4 | 16 boolean proxyFlag = false; |
17 int serverMajor, serverMinor; | |
18 int clientMajor, clientMinor; | |
43 | 19 private boolean normalTermination; |
143 | 20 private TreeVncRootSelectionPanel rootSelectionPanel; |
29 | 21 |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
22 |
31 | 23 public MyRfbProtoClient() { |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
24 |
31 | 25 } |
29 | 26 |
27 public MyRfbProtoClient(Reader reader, String host, String port) { | |
3 | 28 this.reader = reader; |
29 } | |
29 | 30 |
103 | 31 @Override |
32 public boolean isRoot() { | |
33 return false; | |
34 } | |
35 | |
3 | 36 public boolean readProxyFlag() throws TransportException { |
37 int flag = reader.readUInt8(); | |
29 | 38 if (flag == 1) |
3 | 39 return true; |
40 else | |
41 return false; | |
42 } | |
29 | 43 |
44 | |
4 | 45 void sendInitData(OutputStream os) throws IOException { |
20
98519d16a8c3
getInitData from ProtocolContext
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
46 os.write(context.getInitData()); |
4 | 47 } |
29 | 48 |
43 | 49 |
50 @Override | |
51 public void setTerminationType(boolean setType) { | |
52 normalTermination = setType; | |
53 } | |
54 | |
55 @Override | |
56 public boolean getTerminationType() { | |
57 return normalTermination; | |
58 } | |
52 | 59 |
143 | 60 |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
61 public void addHostToSelectionPanel(int port, String hostname,String myHostName) { |
143 | 62 if (rootSelectionPanel != null) { |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
63 rootSelectionPanel.checkBox(Integer.toString(port) + ":" + hostname + ":" + myHostName); |
143 | 64 rootSelectionPanel.setButton(); |
65 rootSelectionPanel.visible(); | |
66 } | |
67 } | |
68 | |
69 @Override | |
144 | 70 public void createRootSelectionPanel(CreateConnectionParam cp) { |
143 | 71 rootSelectionPanel = new TreeVncRootSelectionPanel(); |
144 | 72 rootSelectionPanel.setCp(cp); |
143 | 73 } |
74 | |
75 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
76 /* |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
77 * measure client delay time using tree connection. It should be summed up in upward tree communication |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
78 */ |
66 | 79 @Override |
80 public void readCheckDelay(Reader reader) throws TransportException { | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
81 // ByteBuffer buf = multicastqueue.allocate(24); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
82 // reader.readBytes(buf.array(), 0, 24); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
83 // |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
84 // LinkedList<ByteBuffer> sendData = new LinkedList<ByteBuffer>(); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
85 // sendData.add(buf); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
86 // Socket echoSocket; |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
87 // try { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
88 // echoSocket = new Socket(getProxyAddr(), 10002); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
89 // BufferedReader is = new BufferedReader(new InputStreamReader(echoSocket.getInputStream())); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
90 // DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream()); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
91 // os.writeBytes("checkdelay\n"); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
92 // os.writeBytes(String.valueOf(buf.getLong(16))+"\n"); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
93 // System.out.println("delay"+ is.readLine()); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
94 // } catch (UnknownHostException e) { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
95 // e.printStackTrace(); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
96 // } catch (IOException e) { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
97 // e.printStackTrace(); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
98 // } |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
99 // buf.position(0); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
100 // |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
119
diff
changeset
|
101 // multicastqueue.put(sendData); |
66 | 102 |
103 } | |
3 | 104 } |