annotate src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 248:e6abf4b0c92e

add numberOfRectangle in checkDelay
author Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
date Fri, 24 Oct 2014 14:38:55 +0900
parents 1819e9c5d0cd
children 6ce5b8dd4525
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
758d025ee24b add TextBox.java
one
parents: 31
diff changeset
1 package jp.ac.u_ryukyu.treevnc;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
2
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
3 import java.io.IOException;
206
2b3eb4a9492f MyRfbProto reorganization
oc
parents: 205
diff changeset
4 import java.io.OutputStream;
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
5 import java.io.UnsupportedEncodingException;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
6 import java.net.BindException;
201
ced24de3f2c5 get network interfaces.
oc
parents: 194
diff changeset
7 import java.net.NetworkInterface;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
8 import java.net.ServerSocket;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
9 import java.net.Socket;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
10 import java.net.UnknownHostException;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
11 import java.nio.ByteBuffer;
109
457f9dfbf7ce minor fix.
oc
parents: 107
diff changeset
12 import java.nio.ByteOrder;
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
13 import java.util.Iterator;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
14 import java.util.LinkedList;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
15 import java.util.concurrent.atomic.AtomicInteger;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
16 import java.util.zip.DataFormatException;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
17 import java.util.zip.Deflater;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
18 import java.util.zip.Inflater;
150
925fb2090282 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
19
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
20 import com.glavsoft.exceptions.TransportException;
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
21 import com.glavsoft.rfb.client.ClientToServerMessage;
96
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
22 import com.glavsoft.rfb.encoding.EncodingType;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
23 import com.glavsoft.rfb.protocol.Protocol;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
24 import com.glavsoft.rfb.protocol.ProtocolContext;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
25 import com.glavsoft.transport.Reader;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
26 import com.glavsoft.transport.Writer;
153
e68dfd1972ac fix bad names.
oc
parents: 150
diff changeset
27 import com.glavsoft.viewer.ViewerInterface;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
28 import com.glavsoft.viewer.swing.ConnectionParams;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
29
124
214d4f206431 add TreeVNC command number.
oc
parents: 123
diff changeset
30
207
b31903e5b02d rename myRFBProto
oc
parents: 206
diff changeset
31 public class TreeRFBProto {
231
0e0e6744432c get new nodeList for checkDelay.
oc
parents: 230
diff changeset
32
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
33 final static int FramebufferUpdateRequest = 3;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
34 final static int CheckDelay = 11;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
35 protected final static int FramebufferUpdate = 0;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
36 protected ProtocolContext context;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
37 private int clients = 0;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
38 public MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
39 private RequestScreenThread rThread;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
40 public int acceptPort = 0;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
41 private String myAddress;
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
42 protected boolean readyReconnect = false;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
43 private boolean cuiVersion;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
44 private long counter = 0; // packet serial number
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
45 public ServerSocket servSock;
123
233e94a7b5ed add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
46 private boolean permitChangeScreen = true;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
47 private static final int INFLATE_BUFSIZE = 1024 * 100;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
48 private Inflater inflater = new Inflater();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
49 private Deflater deflater = new Deflater();
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
50 ViewerInterface viewer;
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
51 private short id; // my tree node id ( = 0 in root )
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
52 private boolean leader;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
53 private TreeVncCommandChannelListener acceptThread;
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
54 private boolean firstTime = true;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
55 private TreeRootFinderListener getCast;
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
56 private CreateConnectionParam cp;
178
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
57 private boolean hasViewer = false;
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
58 public boolean showTreeNode = false;
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
59 private boolean reconnecting;
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
60 private short reconnectingId; // Change Server Request to id's node VNC server
205
614db20d8fab try to separate Network management
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 204
diff changeset
61 private TreeVNCNetwork nets = new TreeVNCNetwork();
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
62 private boolean normalTermination;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
63 private TreeVncRootSelectionPanel rootSelectionPanel;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
64 private boolean isTreeManager;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
65 private String vncInterface;
231
0e0e6744432c get new nodeList for checkDelay.
oc
parents: 230
diff changeset
66 public LinkedList<TreeVNCNode> nodeList;
240
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
67 public boolean checkDelay = false;
241
b21a7842a41d add option addSerialNum.
oc
parents: 240
diff changeset
68 public boolean addSerialNum = false;
231
0e0e6744432c get new nodeList for checkDelay.
oc
parents: 230
diff changeset
69
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
70
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
71 public TreeRFBProto(boolean isTreeManager) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
72 rThread = new RequestScreenThread(this);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
73 nets.setMyRfb(this);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
74 this.isTreeManager = isTreeManager;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
75 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
76
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
77 public boolean isTreeManager() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
78 return isTreeManager;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
79 }
207
b31903e5b02d rename myRFBProto
oc
parents: 206
diff changeset
80
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
81 public ProtocolContext getContext() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
82 return context;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
83 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
84
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
85 /**
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
86 * handle new client accept
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
87 * it also handle TreeVNC Command
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
88 * @param newCli
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
89 * @param os
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
90 * @param is
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
91 * @throws IOException
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
92 * @throws TransportException
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
93 */
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
94 public void newClient(final Socket newCli,final Writer os, final Reader is) {
124
214d4f206431 add TreeVNC command number.
oc
parents: 123
diff changeset
95
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
96 final int myId = clients;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
97 final MulticastQueue.Client<LinkedList<ByteBuffer>> c = multicastqueue.newClient();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
98 final AtomicInteger writerRunning = new AtomicInteger();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
99 writerRunning.set(1);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
100 /**
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
101 * Timeout thread. If a client is suspended, it has top of queue
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
102 * indefinitely, which caused memory overflow. After the timeout, we
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
103 * poll the queue and discard it. Start long wait if writer is running.
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
104 */
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
105 final Runnable timer = new Runnable() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
106 public void run() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
107 int count = 0;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
108 for (;;) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
109 long timeout = 50000 / 8;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
110 try {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
111 synchronized (this) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
112 int state, flag;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
113 writerRunning.set(0);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
114 wait(timeout);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
115 flag = 0;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
116 while ((state = writerRunning.get()) == 0) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
117 c.poll(); // discard, should be timeout
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
118 count++;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
119 if (flag == 0) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
120 System.out.println("Discarding " + myId
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
121 + " count=" + count);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
122 flag = 1;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
123 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
124 wait(10); // if this is too short, writer cannot
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
125 // take the poll, if this is too
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
126 // long, memory will overflow...
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
127 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
128 if (flag == 1)
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
129 System.out.println("Resuming " + myId
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
130 + " count=" + count);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
131 if (state != 1) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
132 System.out.println("Client died " + myId);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
133 break;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
134 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
135 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
136 } catch (InterruptedException e) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
137 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
138 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
139 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
140 };
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
141 new Thread(timer, "timer-discard-multicastqueue").start();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
142 /**
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
143 * handle command from lower node
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
144 */
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
145 final Runnable reader = new Runnable() {
122
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
146 public void run() {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
147 for (;;) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
148 try {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
149 final byte b[] = new byte[4096];
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
150 final int c = is.readByte(b);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
151 if (c <= 0)
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
152 throw new IOException();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
153 if (isTreeManager()) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
154 if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
155 if (permitChangeScreen()) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
156 ByteBuffer buf = ByteBuffer.wrap(b);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
157 buf.order(ByteOrder.BIG_ENDIAN);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
158 short id = buf.getShort(2);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
159 int length = buf.getInt(4);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
160 if (length == 0)
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
161 continue;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
162 String newHostName = new String(b, 8, length);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
163 System.out.println("Root server change request :" + newHostName);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
164 // please remove these numbers.
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
165 if (viewer != null) {
230
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
166 changeVNCServer(viewer, newHostName, 3200, 1980, id);
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
167 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
168 } else {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
169 continue;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
170 }
230
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
171 } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) {
248
e6abf4b0c92e add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents: 245
diff changeset
172
e6abf4b0c92e add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents: 245
diff changeset
173 int numberOfRectangle = context.getNumberOfRectangle();
e6abf4b0c92e add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents: 245
diff changeset
174 System.out.println("numberOfRectAngle : " + numberOfRectangle);
e6abf4b0c92e add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents: 245
diff changeset
175
230
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
176 ByteBuffer buf = ByteBuffer.wrap(b);
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
177 buf.order(ByteOrder.BIG_ENDIAN);
233
26b7c0a6d91b fix indent.
oc
parents: 232
diff changeset
178 // getNodeNum(port, hostname, localhostname);
234
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
179 buf.getShort();
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
180 Long time = buf.getLong();
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
181 int port = buf.getInt();
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
182 int addressLength = buf.getInt();
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
183 byte[] byteAddress = new byte[addressLength];
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
184 buf.get(byteAddress);
8479ad028ec7 fix checkdelay send and get.
oc
parents: 233
diff changeset
185 String address = new String(byteAddress, "UTF-8");
235
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
186 int nodeNum = getNodeNum(port, address);
230
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
187 Long delay = System.currentTimeMillis() - time;
244
8cc07511b1d5 small fix checkDelay
oc
parents: 243
diff changeset
188 double halfDelay = (double) delay / 2;
8cc07511b1d5 small fix checkDelay
oc
parents: 243
diff changeset
189 System.out.println("nodeNum" + nodeNum + ", port = " + port + ", address = " + address + ", delay = " + halfDelay);
248
e6abf4b0c92e add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents: 245
diff changeset
190
239
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
191 // checkNodeNum();
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
192 // readSendData(check);
248
e6abf4b0c92e add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents: 245
diff changeset
193
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
194 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
195 } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
196 ClientToServerMessage sc = new ClientToServerMessage() {
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
197 @Override
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
198 public void send(Writer writer)
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
199 throws TransportException {
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
200 writer.write(b,0,c);
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
201 }
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
202 };
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
203 context.sendMessage(sc);
230
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
204 } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) {
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
205 ClientToServerMessage checkDelayReply = new ClientToServerMessage() {
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
206 @Override
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
207 public void send(Writer writer)
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
208 throws TransportException {
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
209 writer.write(b,0,c);
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
210 }
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
211 };
f4ea9ff04741 reply checkdelay
oc
parents: 229
diff changeset
212 context.sendMessage(checkDelayReply);
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
213 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
214 } catch (Exception e) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
215 try {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
216 writerRunning.set(2);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
217 os.close();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
218 is.close();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
219 break;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
220 } catch (IOException e1) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
221 } catch (TransportException e1) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
222 e1.printStackTrace();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
223 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
224 return;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
225 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
226 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
227 }
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
228
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
229 };
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
230 /**
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
231 * send packets to a client (one thread for each client )
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
232 */
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
233 Runnable sender = new Runnable() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
234 public void run() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
235 writerRunning.set(1);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
236 try {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
237 requestThreadNotify();
239
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
238
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
239 // after this, we discard upward packet.
239
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
240 new Thread(reader, "upward-packet-processing").start();
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
241
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
242 for (;;) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
243 LinkedList<ByteBuffer> bufs = c.poll();
239
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
244
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
245 int inputIndex = 0;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
246 ByteBuffer header = bufs.get(inputIndex);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
247 if (header == null)
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
248 continue;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
249 writeToClient(os, bufs, inputIndex);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
250 writerRunning.set(1); // yes my client is awaking.
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
251 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
252 } catch (Exception e) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
253 try {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
254 writerRunning.set(2);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
255 os.close();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
256 } catch (IOException e1) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
257 System.out.println("root writer close faild :" + e1);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
258 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
259 System.out.println("root writer faild :" + e);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
260 /* if socket closed cliList.remove(newCli); */
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
261 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
262 }
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
263
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
264 public void writeToClient(final Writer os,
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
265 LinkedList<ByteBuffer> bufs, int inputIndex)
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
266 throws TransportException {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
267 while (inputIndex < bufs.size()) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
268 ByteBuffer b = bufs.get(inputIndex++);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
269 os.write(b.array(), b.position(), b.limit());
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
270 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
271 os.flush();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
272 bufs = null;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
273 multicastqueue.heapAvailable();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
274 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
275 };
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
276 clients++;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
277 new Thread(sender, "writer-to-lower-node").start();
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
278
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
279 }
157
7cea8789387b thread base command listening loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
280
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
281
122
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
282
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
283 public boolean permitChangeScreen() {
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
284 return permitChangeScreen;
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
285 }
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
286
122
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
287
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
288 public void setPermitChangeScreen(boolean v) {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
289 permitChangeScreen = v;
122
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
290 }
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
291
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
292 public void requestThreadNotify() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
293 rThread.reStart();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
294 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
295
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
296
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
297 public void setProtocolContext(Protocol workingProtocol) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
298 context = workingProtocol;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
299 }
29
57eb5575e6c4 MyRfbProto for client and proxy.
one
parents: 28
diff changeset
300
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
301 public Socket accept() throws IOException {
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
302 return servSock.accept();
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
303 }
31
872d9bcbfe56 Before changing the Viewer.
one
parents: 29
diff changeset
304
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
305 public int selectPort(int p) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
306 int port = p;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
307 while (true) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
308 try {
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
309 servSock = new ServerSocket(port);
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
310 acceptPort = port;
181
9c02b5a72bf9 fix root myAddress.
oc
parents: 179
diff changeset
311 myAddress = "127.0.0.1";
207
b31903e5b02d rename myRFBProto
oc
parents: 206
diff changeset
312 nets.getNetworkInterfaces();
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
313 break;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
314 } catch (BindException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
315 port++;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
316 continue;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
317 } catch (IOException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
318
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
319 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
320 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
321 System.out.println("accept port = " + port);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
322 return port;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
323 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
324
33
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
325
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
326
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
327 public void writeFramebufferUpdateRequest(int x, int y, int w, int h,
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
328 boolean incremental) throws TransportException {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
329 byte[] b = new byte[10];
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
330
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
331 b[0] = (byte) FramebufferUpdateRequest; // 3 is FrameBufferUpdateRequest
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
332 b[1] = (byte) (incremental ? 1 : 0);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
333 b[2] = (byte) ((x >> 8) & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
334 b[3] = (byte) (x & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
335 b[4] = (byte) ((y >> 8) & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
336 b[5] = (byte) (y & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
337 b[6] = (byte) ((w >> 8) & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
338 b[7] = (byte) (w & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
339 b[8] = (byte) ((h >> 8) & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
340 b[9] = (byte) (h & 0xff);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
341 }
33
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
342
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
343 public void setViewer(ViewerInterface v) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
344 viewer = v;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
345 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
346
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
347 public ViewerInterface getViewer() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
348 return viewer;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
349 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
350
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
351
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
352 void sendInitData(OutputStream os) throws IOException {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
353 os.write(context.getInitData());
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
354 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
355
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
356
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
357 public void setTerminationType(boolean setType) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
358 normalTermination = setType;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
359 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
360
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
361 public boolean getTerminationType() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
362 return normalTermination;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
363 }
43
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
364
206
2b3eb4a9492f MyRfbProto reorganization
oc
parents: 205
diff changeset
365
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
366 public void addHostToSelectionPanel(int port, String hostname,String myHostName) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
367 if (rootSelectionPanel != null) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
368 rootSelectionPanel.checkBox(Integer.toString(port) + ":" + hostname + ":" + myHostName);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
369 rootSelectionPanel.setButton();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
370 rootSelectionPanel.visible();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
371 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
372 }
43
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
373
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
374 public void createRootSelectionPanel(CreateConnectionParam cp) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
375 rootSelectionPanel = new TreeVncRootSelectionPanel();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
376 rootSelectionPanel.setCp(cp);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
377 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
378
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
379 public void close() {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
380 // none
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
381 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
382
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
383 public int getAcceptPort() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
384 return acceptPort;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
385 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
386
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
387 public boolean getReadyReconnect() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
388 return readyReconnect;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
389 }
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
390
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
391
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
392 public boolean getCuiVersion() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
393 return cuiVersion;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
394 }
66
84ad879891e9 dont move
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
395
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
396 public void setCuiVersion(boolean flag) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
397 cuiVersion = flag;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
398 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
399
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
400 public void readCheckDelay(Reader reader) throws TransportException {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
401
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
402 }
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
403
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
404 public synchronized void vncConnected(boolean ready) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
405 if (ready && reconnecting) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
406 Socket vncSocket = viewer.getVNCSocket();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
407 NetworkInterface ni = nets.getInterface(vncSocket);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
408 if (ni!=null) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
409 vncInterface = ni.getName();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
410 System.out.println("VNCNetworkInterface :" + vncInterface);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
411 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
412 sendDesktopSizeChange(reconnectingId);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
413 reconnecting = false;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
414 if (reconnectingId == 0) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
415 viewer.setVisible(false);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
416 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
417 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
418 if (reconnectingId!=0) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
419 readyReconnect = ready;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
420 if (ready) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
421 notifyAll();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
422 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
423 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
424 }
94
75879c316796 synchronized wait for Rfb initialization in change server.
oc
parents: 89
diff changeset
425
202
22676ca0dd97 get VNC Socket.
oc
parents: 201
diff changeset
426
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
427 public synchronized void waitForVNCConnection() throws InterruptedException {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
428 if (reconnectingId!=0) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
429 while (!readyReconnect) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
430 wait();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
431 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
432 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
433 }
96
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
434
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
435
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
436 public void sendDesktopSizeChange(short id) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
437 LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
438 int width = context.getFbWidth();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
439 int height = context.getFbHeight();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
440 desktopSize.add(new UpdateRectangleMessage(width, height, EncodingType.INIT_DATA, context.getInitData(),id).getMessage());
242
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
441 addSerialNumber(desktopSize);
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
442 multicastqueue.put(desktopSize);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
443 }
98
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
444
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
445
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
446 public void addSerialNumber(LinkedList<ByteBuffer> bufs) {
242
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
447 ByteBuffer serialNum = multicastqueue.allocate(4+8); // addSerialNum flag + SerialNum
243
0ed7719c1800 fix serial number option.
oc
parents: 242
diff changeset
448 if (this.addSerialNum) {
0ed7719c1800 fix serial number option.
oc
parents: 242
diff changeset
449 serialNum.putInt(1);
0ed7719c1800 fix serial number option.
oc
parents: 242
diff changeset
450 } else {
0ed7719c1800 fix serial number option.
oc
parents: 242
diff changeset
451 serialNum.putInt(0);
0ed7719c1800 fix serial number option.
oc
parents: 242
diff changeset
452 }
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
453 serialNum.putLong(counter++);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
454 serialNum.flip();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
455 bufs.addFirst(serialNum);
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
456 }
102
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
457
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
458
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
459 public void resetDecoder() {
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
460 context.resetDecoder();
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
461 }
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
462
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
463 public void stopReceiverTask() {
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
464 if (context!=null)
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
465 context.cleanUpSession(null);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
466 // cleanup zlib decoder for new VNCServer
202
22676ca0dd97 get VNC Socket.
oc
parents: 201
diff changeset
467 if (isTreeManager())
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
468 inflater = new Inflater();
102
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
469 }
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
470
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
471 public String getMyAddress() {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
472 return myAddress;
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
473 }
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
474
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
475 /**
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
476 * gzip byte arrays
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
477 *
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
478 * @param deflater
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
479 * @param inputs
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
480 * byte data[]
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
481 * @param inputIndex
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
482 * @param outputs
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
483 * byte data[]
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
484 * @return byte length in last byte array
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
485 * @throws IOException
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
486 */
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
487 public int zip(Deflater deflater, LinkedList<ByteBuffer> inputs,
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
488 int inputIndex, LinkedList<ByteBuffer> outputs) throws IOException {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
489 int len = 0;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
490 ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
491 while (inputIndex < inputs.size()) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
492 ByteBuffer b1 = inputs.get(inputIndex++);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
493 deflater.setInput(b1.array(), b1.position(), b1.remaining());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
494 /**
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
495 * If we finish() stream and reset() it, Deflater start new gzip
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
496 * stream, this makes continuous zlib reader unhappy. if we remove
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
497 * finish(), Deflater.deflate() never flushes its output. The
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
498 * original zlib deflate has flush flag. I'm pretty sure this a kind
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
499 * of bug of Java library.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
500 */
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
501 if (inputIndex == inputs.size())
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
502 deflater.finish();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
503 int len1 = 0;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
504 do {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
505 len1 = deflater.deflate(c1.array(), c1.position(),
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
506 c1.remaining());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
507 if (len1 > 0) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
508 len += len1;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
509 c1.position(c1.position() + len1);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
510 if (c1.remaining() == 0) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
511 c1.flip();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
512 outputs.addLast(c1);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
513 c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
514 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
515 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
516 } while (len1 > 0 || !deflater.needsInput()); // &&!deflater.finished());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
517 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
518 if (c1.position() != 0) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
519 c1.flip();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
520 outputs.addLast(c1);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
521 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
522 deflater.reset();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
523 return len;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
524 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
525
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
526 /**
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
527 * gunzip byte arrays
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
528 *
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
529 * @param inflater
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
530 * @param inputs
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
531 * byte data[]
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
532 * @param bytes
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
533 * byte data[]
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
534 * @return number of total bytes
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
535 * @throws IOException
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
536 */
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
537 public int unzip(Inflater inflater, LinkedList<ByteBuffer> inputs,
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
538 int inputIndex, byte[] bytes, int bufSize)
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
539 throws DataFormatException {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
540 int position = 0;
b3426724667b fix read send data.
oc
parents: 181
diff changeset
541 int limit = bytes.length;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
542 while (inputIndex < inputs.size()) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
543 ByteBuffer input = inputs.get(inputIndex++);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
544 inflater.setInput(input.array(), input.position(), input.limit());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
545 // if (inputIndex==inputs.size()) if inflater/deflater has symmetry,
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
546 // we need this
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
547 // inflater.end(); but this won't work
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
548 do {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
549 int len0 = inflater.inflate(bytes, position,
b3426724667b fix read send data.
oc
parents: 181
diff changeset
550 limit-position);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
551 if (len0 > 0) {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
552 position += len0;
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
553 if (position > limit) {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
554 throw new DataFormatException();
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
555 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
556 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
557 } while (!inflater.needsInput());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
558 }
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
559 return position;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
560 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
561
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
562 /**
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
563 * read FrameBuffferUpdate. If it is ZLE, make it ZLEE which is self contained compressed packet.
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
564 * put the packet to the multicastqueue. Then normal rendering engine read the same stream using is.reset().
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
565 * @param dataLen
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
566 * @param reader
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
567 * @throws TransportException
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
568 * @throws UnsupportedEncodingException
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
569 */
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
570 public void readSendData(int dataLen, Reader reader, byte[] bytes)
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
571 throws TransportException, UnsupportedEncodingException {
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
572 LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
573 ByteBuffer header = multicastqueue.allocate(16);
242
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
574 ByteBuffer serial = multicastqueue.allocate(4+8);
202
22676ca0dd97 get VNC Socket.
oc
parents: 201
diff changeset
575 if (!isTreeManager()) {
242
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
576 reader.readBytes(serial.array(),0,4+8);
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
577 serial.limit(4+8);
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
578 }
185
feefc1e58153 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 182
diff changeset
579 reader.mark(dataLen);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
580 reader.readBytes(header.array(), 0, 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
581 header.limit(16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
582 if (header.get(0) == FramebufferUpdate) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
583 int encoding = header.getInt(12);
239
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
584
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
585 if (encoding == EncodingType.ZRLE.getId()
229
5eb8aa65f387 fix checkdelay number-of-rectangle, and send checkdelay to lower node.
oc
parents: 227
diff changeset
586 || encoding == EncodingType.ZLIB.getId()) {
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
587 // recompress into ZREE
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
588 // uncompressed result is remain in bytes
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
589 ByteBuffer len = multicastqueue.allocate(4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
590 reader.readBytes(len.array(), 0, 4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
591 len.limit(4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
592 ByteBuffer inputData = multicastqueue.allocate(dataLen - 20);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
593 reader.readBytes(inputData.array(), 0, inputData.capacity());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
594 inputData.limit(dataLen - 20);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
595 LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
596 inputs.add(inputData);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
597 header.putInt(12, EncodingType.ZRLEE.getId()); // means
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
598 // recompress
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
599 // every time
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
600 // using new Deflecter every time is incompatible with the
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
601 // protocol, clients have to be modified.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
602 Deflater nDeflater = deflater; // new Deflater();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
603 LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
604 try {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
605 unzip(inflater, inputs, 0, bytes, INFLATE_BUFSIZE);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
606 // dump32(inputs);
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
607 out.add(ByteBuffer.wrap(bytes));
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
608 int len2 = zip(nDeflater, out, 0, bufs);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
609 ByteBuffer blen = multicastqueue.allocate(4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
610 blen.putInt(len2);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
611 blen.flip();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
612 bufs.addFirst(blen);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
613 bufs.addFirst(header);
242
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
614 addSerialNumber(bufs);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
615 multicastqueue.put(bufs);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
616 } catch (DataFormatException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
617 throw new TransportException(e);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
618 } catch (IOException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
619 throw new TransportException(e);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
620 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
621 return;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
622 }
233
26b7c0a6d91b fix indent.
oc
parents: 232
diff changeset
623
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
624 // ZRLEE is already compressed
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
625 bufs.add(header);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
626 if (dataLen > 16) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
627 ByteBuffer b = multicastqueue.allocate(dataLen - 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
628 reader.readBytes(b.array(), 0, dataLen - 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
629 b.limit(dataLen - 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
630 bufs.add(b);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
631 }
242
a640cd7001e1 fix checkdelay, and fix serial number option
oc
parents: 241
diff changeset
632 this.addSerialNumber(bufs);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
633 multicastqueue.put(bufs);
233
26b7c0a6d91b fix indent.
oc
parents: 232
diff changeset
634
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
635 return;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
636 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
637 // It may be compressed. We can inflate here to avoid repeating clients
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
638 // decompressing here,
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
639 // but it may generate too many large data. It is better to do it in
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
640 // each client.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
641 // But we have do inflation for all input data, so we have to do it
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
642 // here.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
643 }
124
214d4f206431 add TreeVNC command number.
oc
parents: 123
diff changeset
644
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
645 public void setId(short id) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
646 this.id = id;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
647 }
169
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
648
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
649 public short getId() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
650 return id;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
651 }
169
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
652
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
653 public void setMyAddress(String myHostName) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
654 this.myAddress = myHostName;
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
655
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
656 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
657
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
658 public void setLeader(boolean leader) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
659 this.leader = leader;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
660 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
661
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
662 public boolean isLeader() {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
663 return leader;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
664 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
665
203
2f6237fea67e change createTreeManagers timing.
oc
parents: 202
diff changeset
666 public void setTreeManager(String intf, TreeManagement clients) {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
667 nets.setTreeManager(intf, clients);
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
668 }
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
669
203
2f6237fea67e change createTreeManagers timing.
oc
parents: 202
diff changeset
670 public TreeManagement getTreeManager(String intf) {
231
0e0e6744432c get new nodeList for checkDelay.
oc
parents: 230
diff changeset
671 TreeManagement tm = nets.getTreeManager(intf);
0e0e6744432c get new nodeList for checkDelay.
oc
parents: 230
diff changeset
672 this.nodeList = tm.getList();
0e0e6744432c get new nodeList for checkDelay.
oc
parents: 230
diff changeset
673 return tm;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
674 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
675
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
676 /**
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
677 * chnageVNCServer is called when host change.
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
678 *
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
679 * @param vncProxyService
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
680 * @param hostName
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
681 * HostAddress
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
682 * @param width
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
683 * FrameWidth
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
684 * @param height
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
685 * FrameHeight
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
686 * @param id
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
687 * @throws InterruptedException
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
688 */
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
689 public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int width, int height, short id)
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
690 throws UnknownHostException, IOException, InterruptedException {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
691 // stop reader stop
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
692 stopReceiverTask();
192
aa00e4b2fc27 fix root viewer.
oc
parents: 191
diff changeset
693 reconnectingId = id;
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
694 vncProxyService.inhelitClients(vncProxyService, hostName);
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
695 // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
696 reconnecting = true;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
697 if (reconnectingId!=0) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
698 waitForVNCConnection();
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
699 }
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
700 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
701
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
702 /**
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
703 * start accepting children
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
704 * run rootFinderListener if necessary
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
705 */
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
706 public void createConnectionAndStart(ViewerInterface v) {
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
707 selectPort(ConnectionParams.DEFAULT_VNC_ROOT);
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
708 startTreeVncCommandListener();
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
709 if(isTreeManager() && firstTime) {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
710 getCast = new TreeRootFinderListener(v);
239
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
711 Thread treeRootFindThread = new Thread(getCast, "tree-root-find-listener");
d655db005535 create sendCheckDelay Socket.
oc
parents: 237
diff changeset
712 treeRootFindThread.start();
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
713 firstTime = false;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
714 }
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
715 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
716
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
717 public void startTreeVncCommandListener() {
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
718 acceptThread = new TreeVncCommandChannelListener(this, getAcceptPort());
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
719 Thread thread = new Thread(acceptThread, "TreeVNC-accept");
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
720 thread.start();
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
721 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
722
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
723 public TreeVncCommandChannelListener getAcceptThread() {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
724 return acceptThread;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
725 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
726
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
727 public void setConnectionParam(CreateConnectionParam createConnectionParam) {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
728 cp = createConnectionParam;
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
729 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
730
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
731 public CreateConnectionParam getConnectionParam() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
732 return cp;
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
733 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
734
178
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
735 public boolean hasViewer() {
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
736 return hasViewer;
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
737 }
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
738
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
739 public void setHasViewer(boolean b) {
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
740 hasViewer = b;
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
741 }
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
742
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
743 public void setReconnecting(boolean b) {
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
744 reconnecting = b;
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
745 }
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
746
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
747 public int getReconnectingId() {
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
748 return reconnectingId;
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
749 }
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
750
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
751 public void setShowTree(boolean showTree) {
240
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
752 this.showTreeNode = showTree;
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
753 }
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
754
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
755 public void setCheckDelay(boolean checkDelay) {
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
756 this.checkDelay = checkDelay;
223
3189e210a7ed indent fix.
oc
parents: 207
diff changeset
757 }
194
b038aafeb2b0 hide VNC server's view to prevent video feed back.
oc
parents: 192
diff changeset
758
241
b21a7842a41d add option addSerialNum.
oc
parents: 240
diff changeset
759 public void setAddSerialNum(boolean addSerialNum) {
b21a7842a41d add option addSerialNum.
oc
parents: 240
diff changeset
760 this.addSerialNum = addSerialNum;
b21a7842a41d add option addSerialNum.
oc
parents: 240
diff changeset
761 }
b21a7842a41d add option addSerialNum.
oc
parents: 240
diff changeset
762
235
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
763 public int getNodeNum(int port, String address) {
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
764 int nodeNum = 0;
235
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
765
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
766 for (Iterator<TreeVNCNode> i = nodeList.iterator(); i.hasNext();) {
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
767 TreeVNCNode tvn = (TreeVNCNode)i.next();
235
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
768 if (port == tvn.port && address.equals(tvn.hostname)) {
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
769 nodeNum = tvn.treeNum;
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
770 return nodeNum;
15e66adbb8bb get checkdelay nodeNum.
oc
parents: 234
diff changeset
771 }
232
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
772 }
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
773 return nodeNum;
6ee4cdca104c send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents: 231
diff changeset
774 }
241
b21a7842a41d add option addSerialNum.
oc
parents: 240
diff changeset
775
240
7310e7d7a45f add option --checkDelay.
oc
parents: 239
diff changeset
776 }