Mercurial > hg > Applications > TreeVNC
annotate src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 318:d01d56038dd1
try catch unzip inflate error.
author | oc |
---|---|
date | Thu, 29 Jan 2015 14:16:59 +0900 |
parents | 3c63bc88383e |
children | a237c7e3b7ca |
rev | line source |
---|---|
32 | 1 package jp.ac.u_ryukyu.treevnc; |
28 | 2 |
3 import java.io.IOException; | |
206 | 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; |
291 | 6 import java.net.*; |
28 | 7 import java.nio.ByteBuffer; |
109 | 8 import java.nio.ByteOrder; |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
9 import java.util.Iterator; |
28 | 10 import java.util.LinkedList; |
11 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
|
12 import java.util.zip.DataFormatException; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
13 import java.util.zip.Deflater; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
14 import java.util.zip.Inflater; |
150 | 15 |
28 | 16 import com.glavsoft.exceptions.TransportException; |
107 | 17 import com.glavsoft.rfb.client.ClientToServerMessage; |
96 | 18 import com.glavsoft.rfb.encoding.EncodingType; |
264 | 19 import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; |
28 | 20 import com.glavsoft.rfb.protocol.Protocol; |
21 import com.glavsoft.rfb.protocol.ProtocolContext; | |
22 import com.glavsoft.transport.Reader; | |
23 import com.glavsoft.transport.Writer; | |
153 | 24 import com.glavsoft.viewer.ViewerInterface; |
174 | 25 import com.glavsoft.viewer.swing.ConnectionParams; |
28 | 26 |
124 | 27 |
207 | 28 public class TreeRFBProto { |
231 | 29 |
223 | 30 final static int FramebufferUpdateRequest = 3; |
31 final static int CheckDelay = 11; | |
32 protected final static int FramebufferUpdate = 0; | |
33 protected ProtocolContext context; | |
34 private int clients = 0; | |
35 public MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); | |
36 private RequestScreenThread rThread; | |
37 public int acceptPort = 0; | |
174 | 38 private String myAddress; |
223 | 39 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
|
40 public ServerSocket servSock; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
41 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
|
42 private Inflater inflater = new Inflater(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
43 private Deflater deflater = new Deflater(); |
174 | 44 ViewerInterface viewer; |
223 | 45 private short id; // my tree node id ( = 0 in root ) |
174 | 46 private TreeVncCommandChannelListener acceptThread; |
47 private TreeRootFinderListener getCast; | |
176 | 48 private CreateConnectionParam cp; |
187 | 49 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
|
50 private TreeVNCNetwork nets = new TreeVNCNetwork(); |
223 | 51 private TreeVncRootSelectionPanel rootSelectionPanel; |
52 private String vncInterface; | |
231 | 53 public LinkedList<TreeVNCNode> nodeList; |
267 | 54 |
55 protected boolean readyReconnect = false; | |
56 private boolean cuiVersion; | |
57 private boolean permitChangeScreen = true; | |
58 private boolean leader; | |
59 private boolean firstTime = true; | |
60 private boolean hasViewer = false; | |
61 private boolean reconnecting; | |
62 private boolean normalTermination; | |
63 private boolean isTreeManager; | |
64 public boolean showTreeNode = false; | |
240 | 65 public boolean checkDelay = false; |
241 | 66 public boolean addSerialNum = false; |
257 | 67 public boolean fixingSize = false; |
267 | 68 public boolean filterSingleDisplay = false; |
69 | |
257 | 70 public int frameSizeWidth; |
71 public int frameSizeHeight; | |
72 public int fixingSizeWidth; | |
73 public int fixingSizeHeight; | |
74 | |
306 | 75 private int singleWidth = 0; |
76 private int singleHeight = 0; | |
301 | 77 |
293 | 78 private DatagramSocket socket = null; |
275 | 79 |
306 | 80 private byte[] originalInitData = null; |
81 | |
223 | 82 public TreeRFBProto(boolean isTreeManager) { |
83 rThread = new RequestScreenThread(this); | |
84 nets.setMyRfb(this); | |
85 this.isTreeManager = isTreeManager; | |
302 | 86 // this.socket = createSocket(); |
223 | 87 } |
88 | |
89 public boolean isTreeManager() { | |
90 return isTreeManager; | |
91 } | |
207 | 92 |
223 | 93 public ProtocolContext getContext() { |
94 return context; | |
95 } | |
96 | |
97 /** | |
98 * handle new client accept | |
99 * it also handle TreeVNC Command | |
100 * @param newCli | |
101 * @param os | |
102 * @param is | |
103 * @throws IOException | |
104 * @throws TransportException | |
105 */ | |
106 public void newClient(final Socket newCli,final Writer os, final Reader is) { | |
124 | 107 |
223 | 108 final int myId = clients; |
109 final MulticastQueue.Client<LinkedList<ByteBuffer>> c = multicastqueue.newClient(); | |
110 final AtomicInteger writerRunning = new AtomicInteger(); | |
111 writerRunning.set(1); | |
112 /** | |
113 * Timeout thread. If a client is suspended, it has top of queue | |
114 * indefinitely, which caused memory overflow. After the timeout, we | |
115 * poll the queue and discard it. Start long wait if writer is running. | |
116 */ | |
117 final Runnable timer = new Runnable() { | |
118 public void run() { | |
119 int count = 0; | |
120 for (;;) { | |
121 long timeout = 50000 / 8; | |
122 try { | |
123 synchronized (this) { | |
124 int state, flag; | |
125 writerRunning.set(0); | |
126 wait(timeout); | |
127 flag = 0; | |
128 while ((state = writerRunning.get()) == 0) { | |
129 c.poll(); // discard, should be timeout | |
130 count++; | |
131 if (flag == 0) { | |
132 System.out.println("Discarding " + myId | |
133 + " count=" + count); | |
134 flag = 1; | |
135 } | |
136 wait(10); // if this is too short, writer cannot | |
137 // take the poll, if this is too | |
138 // long, memory will overflow... | |
139 } | |
140 if (flag == 1) | |
141 System.out.println("Resuming " + myId | |
142 + " count=" + count); | |
143 if (state != 1) { | |
144 System.out.println("Client died " + myId); | |
145 break; | |
146 } | |
147 } | |
148 } catch (InterruptedException e) { | |
149 } | |
150 } | |
151 } | |
152 }; | |
153 new Thread(timer, "timer-discard-multicastqueue").start(); | |
154 /** | |
155 * handle command from lower node | |
156 */ | |
157 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
|
158 public void run() { |
223 | 159 for (;;) { |
160 try { | |
161 final byte b[] = new byte[4096]; | |
162 final int c = is.readByte(b); | |
163 if (c <= 0) | |
164 throw new IOException(); | |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
165 // case of root node. |
223 | 166 if (isTreeManager()) { |
167 if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { | |
168 if (permitChangeScreen()) { | |
169 ByteBuffer buf = ByteBuffer.wrap(b); | |
170 buf.order(ByteOrder.BIG_ENDIAN); | |
257 | 171 buf.get(); |
172 buf.get(); | |
173 short id = buf.getShort(); | |
174 int length = buf.getInt(); | |
223 | 175 if (length == 0) |
257 | 176 continue; |
177 byte[] byteAddress = new byte[length]; | |
178 buf.get(byteAddress); | |
179 String newHostName = new String(byteAddress, "UTF-8"); | |
180 int frameSizeWidth = buf.getInt(); | |
181 int frameSizeHeight = buf.getInt(); | |
223 | 182 System.out.println("Root server change request :" + newHostName); |
183 // please remove these numbers. | |
184 if (viewer != null) { | |
257 | 185 changeVNCServer(viewer, newHostName, frameSizeWidth, frameSizeHeight, id); |
317 | 186 viewer.setFitScreen(); |
223 | 187 } |
188 } else { | |
189 continue; | |
190 } | |
301 | 191 } else if (b[0] == ClientToServerMessage.REQUEST_SINGLE_DISPLAY_SIZE) { |
280
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
192 ByteBuffer buf = ByteBuffer.wrap(b); |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
193 buf.order(ByteOrder.BIG_ENDIAN); |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
194 buf.get(); |
301 | 195 sendSingleDisplaySize(singleWidth, singleHeight); |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
196 } else if (b[0] == ClientToServerMessage.READY_SHARE_SOUND) { |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
197 System.out.println("rootは受信準備を始める。"); |
293 | 198 int rtpPort = selectPort(ConnectionParams.DEFAULT_RTP_PORT); |
199 InetAddress hostname = InetAddress.getLocalHost(); | |
200 ReceiveSound receiveSound = new ReceiveSound(socket); | |
201 Thread receiveSoundThread = new Thread(receiveSound, "receive-sound"); | |
202 receiveSoundThread.start(); | |
230 | 203 } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) { |
204 ByteBuffer buf = ByteBuffer.wrap(b); | |
205 buf.order(ByteOrder.BIG_ENDIAN); | |
234 | 206 buf.getShort(); |
207 Long time = buf.getLong(); | |
208 int port = buf.getInt(); | |
209 int addressLength = buf.getInt(); | |
210 byte[] byteAddress = new byte[addressLength]; | |
211 buf.get(byteAddress); | |
212 String address = new String(byteAddress, "UTF-8"); | |
235 | 213 int nodeNum = getNodeNum(port, address); |
230 | 214 Long delay = System.currentTimeMillis() - time; |
244 | 215 double halfDelay = (double) delay / 2; |
252 | 216 System.out.println(System.currentTimeMillis() + " : receive checkDelay : nodeNum" + nodeNum + ", port : " + port + ", address : " + address + ", delay : " + halfDelay); |
223 | 217 } |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
218 // case of client node. |
223 | 219 } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { |
295 | 220 ClientToServerMessage serverChangeRequest = new ClientToServerMessage() { |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
221 @Override |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
222 public void send(Writer writer) |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
223 throws TransportException { |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
224 writer.write(b,0,c); |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
225 } |
223 | 226 }; |
295 | 227 context.sendMessage(serverChangeRequest); |
301 | 228 } else if (b[0] == ClientToServerMessage.REQUEST_SINGLE_DISPLAY_SIZE) { |
295 | 229 ClientToServerMessage requestSingeDisplayWidth = new ClientToServerMessage() { |
280
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
230 @Override |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
231 public void send(Writer writer) |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
232 throws TransportException { |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
233 writer.write(b, 0, c); |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
234 } |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
235 }; |
295 | 236 context.sendMessage(requestSingeDisplayWidth); |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
237 } else if (b[0] == ClientToServerMessage.READY_SHARE_SOUND) { |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
238 ClientToServerMessage readyShareSound = new ClientToServerMessage() { |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
239 @Override |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
240 public void send(Writer writer) |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
241 throws TransportException { |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
242 writer.write(b,0,c); |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
243 } |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
244 }; |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
245 context.sendMessage(readyShareSound); |
230 | 246 } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) { |
247 ClientToServerMessage checkDelayReply = new ClientToServerMessage() { | |
248 @Override | |
249 public void send(Writer writer) | |
250 throws TransportException { | |
251 writer.write(b,0,c); | |
252 } | |
253 }; | |
254 context.sendMessage(checkDelayReply); | |
223 | 255 } |
256 } catch (Exception e) { | |
257 try { | |
258 writerRunning.set(2); | |
259 os.close(); | |
260 is.close(); | |
261 break; | |
262 } catch (IOException e1) { | |
263 } catch (TransportException e1) { | |
264 e1.printStackTrace(); | |
265 } | |
266 return; | |
267 } | |
268 } | |
269 } | |
270 }; | |
271 /** | |
272 * send packets to a client (one thread for each client ) | |
273 */ | |
274 Runnable sender = new Runnable() { | |
275 public void run() { | |
276 writerRunning.set(1); | |
277 try { | |
278 requestThreadNotify(); | |
239 | 279 |
223 | 280 // after this, we discard upward packet. |
239 | 281 new Thread(reader, "upward-packet-processing").start(); |
282 | |
223 | 283 for (;;) { |
284 LinkedList<ByteBuffer> bufs = c.poll(); | |
239 | 285 |
223 | 286 int inputIndex = 0; |
287 ByteBuffer header = bufs.get(inputIndex); | |
288 if (header == null) | |
289 continue; | |
290 writeToClient(os, bufs, inputIndex); | |
291 writerRunning.set(1); // yes my client is awaking. | |
292 } | |
293 } catch (Exception e) { | |
294 try { | |
295 writerRunning.set(2); | |
296 os.close(); | |
297 } catch (IOException e1) { | |
298 System.out.println("root writer close faild :" + e1); | |
299 } | |
300 System.out.println("root writer faild :" + e); | |
301 /* if socket closed cliList.remove(newCli); */ | |
302 } | |
303 } | |
304 public void writeToClient(final Writer os, | |
305 LinkedList<ByteBuffer> bufs, int inputIndex) | |
306 throws TransportException { | |
307 while (inputIndex < bufs.size()) { | |
308 ByteBuffer b = bufs.get(inputIndex++); | |
309 os.write(b.array(), b.position(), b.limit()); | |
310 } | |
311 os.flush(); | |
312 bufs = null; | |
313 multicastqueue.heapAvailable(); | |
314 } | |
315 }; | |
316 clients++; | |
317 new Thread(sender, "writer-to-lower-node").start(); | |
318 } | |
157
7cea8789387b
thread base command listening loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
153
diff
changeset
|
319 |
301 | 320 public void sendSingleDisplaySize(int singleDisplayWidth, int singleDisplayHeight) throws UnsupportedEncodingException { |
305 | 321 LinkedList<ByteBuffer> linkedListSendSingleDisplaySize = new LinkedList<ByteBuffer>(); |
301 | 322 SendSingleDisplaySize sendSingleDisplaySize = new SendSingleDisplaySize(); |
305 | 323 linkedListSendSingleDisplaySize.add(sendSingleDisplaySize.singleDisplaySize(0, 0, singleDisplayWidth, singleDisplayHeight)); |
324 addSerialNumber(linkedListSendSingleDisplaySize); | |
325 multicastqueue.put(linkedListSendSingleDisplaySize); | |
281 | 326 System.out.println(singleDisplayWidth + " : send single display width"); |
327 } | |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
328 |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
329 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
|
330 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
|
331 } |
223 | 332 |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
333 |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
334 public void setPermitChangeScreen(boolean v) { |
223 | 335 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
|
336 } |
223 | 337 |
338 public void requestThreadNotify() { | |
339 rThread.reStart(); | |
340 } | |
341 | |
342 | |
28 | 343 public void setProtocolContext(Protocol workingProtocol) { |
344 context = workingProtocol; | |
345 } | |
29 | 346 |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
347 public Socket accept() throws IOException { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
348 return servSock.accept(); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
349 } |
31 | 350 |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
351 public int selectPort(int p) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
352 int port = p; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
353 while (true) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
354 try { |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
355 servSock = new ServerSocket(port); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
356 acceptPort = port; |
181 | 357 myAddress = "127.0.0.1"; |
207 | 358 nets.getNetworkInterfaces(); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
359 break; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
360 } catch (BindException e) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
361 port++; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
362 continue; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
363 } catch (IOException e) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
364 |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
365 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
366 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
367 System.out.println("accept port = " + port); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
368 return port; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
369 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
370 |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
371 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
372 |
223 | 373 public void writeFramebufferUpdateRequest(int x, int y, int w, int h, |
374 boolean incremental) throws TransportException { | |
375 byte[] b = new byte[10]; | |
376 | |
377 b[0] = (byte) FramebufferUpdateRequest; // 3 is FrameBufferUpdateRequest | |
378 b[1] = (byte) (incremental ? 1 : 0); | |
379 b[2] = (byte) ((x >> 8) & 0xff); | |
380 b[3] = (byte) (x & 0xff); | |
381 b[4] = (byte) ((y >> 8) & 0xff); | |
382 b[5] = (byte) (y & 0xff); | |
383 b[6] = (byte) ((w >> 8) & 0xff); | |
384 b[7] = (byte) (w & 0xff); | |
385 b[8] = (byte) ((h >> 8) & 0xff); | |
386 b[9] = (byte) (h & 0xff); | |
387 } | |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
388 |
223 | 389 public void setViewer(ViewerInterface v) { |
390 viewer = v; | |
391 } | |
392 | |
393 public ViewerInterface getViewer() { | |
394 return viewer; | |
395 } | |
396 | |
397 | |
398 void sendInitData(OutputStream os) throws IOException { | |
399 os.write(context.getInitData()); | |
400 } | |
401 | |
402 | |
403 public void setTerminationType(boolean setType) { | |
404 normalTermination = setType; | |
405 } | |
406 | |
407 public boolean getTerminationType() { | |
408 return normalTermination; | |
409 } | |
43 | 410 |
206 | 411 |
223 | 412 public void addHostToSelectionPanel(int port, String hostname,String myHostName) { |
413 if (rootSelectionPanel != null) { | |
414 rootSelectionPanel.checkBox(Integer.toString(port) + ":" + hostname + ":" + myHostName); | |
415 rootSelectionPanel.setButton(); | |
416 rootSelectionPanel.visible(); | |
417 } | |
418 } | |
43 | 419 |
223 | 420 public void createRootSelectionPanel(CreateConnectionParam cp) { |
421 rootSelectionPanel = new TreeVncRootSelectionPanel(); | |
422 rootSelectionPanel.setCp(cp); | |
423 } | |
424 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
425 public void close() { |
223 | 426 // none |
427 } | |
428 | |
429 public int getAcceptPort() { | |
430 return acceptPort; | |
431 } | |
432 | |
433 public boolean getReadyReconnect() { | |
434 return readyReconnect; | |
435 } | |
65 | 436 |
437 | |
223 | 438 public boolean getCuiVersion() { |
439 return cuiVersion; | |
440 } | |
66 | 441 |
223 | 442 public void setCuiVersion(boolean flag) { |
443 cuiVersion = flag; | |
444 } | |
445 | |
446 public void readCheckDelay(Reader reader) throws TransportException { | |
447 | |
448 } | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
449 |
223 | 450 public synchronized void vncConnected(boolean ready) { |
451 if (ready && reconnecting) { | |
452 Socket vncSocket = viewer.getVNCSocket(); | |
453 NetworkInterface ni = nets.getInterface(vncSocket); | |
454 if (ni!=null) { | |
455 vncInterface = ni.getName(); | |
456 System.out.println("VNCNetworkInterface :" + vncInterface); | |
457 } | |
458 sendDesktopSizeChange(reconnectingId); | |
459 reconnecting = false; | |
460 if (reconnectingId == 0) { | |
461 viewer.setVisible(false); | |
462 } | |
463 } | |
464 if (reconnectingId!=0) { | |
465 readyReconnect = ready; | |
466 if (ready) { | |
467 notifyAll(); | |
468 } | |
469 } | |
470 } | |
94
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
471 |
202 | 472 |
223 | 473 public synchronized void waitForVNCConnection() throws InterruptedException { |
474 if (reconnectingId!=0) { | |
475 while (!readyReconnect) { | |
476 wait(); | |
477 } | |
478 } | |
479 } | |
96 | 480 |
481 | |
223 | 482 public void sendDesktopSizeChange(short id) { |
483 LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>(); | |
484 int width = context.getFbWidth(); | |
485 int height = context.getFbHeight(); | |
304 | 486 byte[] initData = null; |
487 | |
488 if (filterSingleDisplay) { | |
306 | 489 this.originalInitData = createOriginalInitData(singleWidth, singleHeight, context.getRemoteDesktopName()); |
490 desktopSize.add(new ChengeDesktopSize(singleWidth, singleHeight, EncodingType.INIT_DATA, originalInitData, id).getMessage()); | |
305 | 491 } else { |
492 desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); | |
304 | 493 } |
242 | 494 addSerialNumber(desktopSize); |
223 | 495 multicastqueue.put(desktopSize); |
496 } | |
98 | 497 |
306 | 498 public byte[] createOriginalInitData(int singleWidth, int singleHeight, String remoteDesktopName) { |
499 TreeVncCommandChannelListener treeVncCommandChannelListener = new TreeVncCommandChannelListener(this, acceptPort); | |
500 byte[] originalInitData = treeVncCommandChannelListener.createOriginalInitData(singleWidth, singleHeight, remoteDesktopName); | |
501 return originalInitData; | |
502 } | |
503 | |
504 public void setOriginalInitData(int singleWidth, int singleHeight, String remoteDesktopName) { | |
505 TreeVncCommandChannelListener treeVncCommandChannelListener = new TreeVncCommandChannelListener(this, acceptPort); | |
506 originalInitData = treeVncCommandChannelListener.createOriginalInitData(singleWidth, singleHeight, remoteDesktopName); | |
507 } | |
508 | |
509 public byte[] getOriginalInitData() { | |
510 return originalInitData; | |
511 } | |
512 | |
98 | 513 |
223 | 514 public void addSerialNumber(LinkedList<ByteBuffer> bufs) { |
242 | 515 ByteBuffer serialNum = multicastqueue.allocate(4+8); // addSerialNum flag + SerialNum |
243 | 516 if (this.addSerialNum) { |
517 serialNum.putInt(1); | |
518 } else { | |
519 serialNum.putInt(0); | |
520 } | |
223 | 521 serialNum.putLong(counter++); |
522 serialNum.flip(); | |
523 bufs.addFirst(serialNum); | |
524 } | |
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
|
525 |
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
|
526 |
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
|
527 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
|
528 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
|
529 } |
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
|
530 |
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
|
531 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
|
532 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
|
533 context.cleanUpSession(null); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
534 // cleanup zlib decoder for new VNCServer |
202 | 535 if (isTreeManager()) |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
536 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
|
537 } |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
538 |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
539 public String getMyAddress() { |
174 | 540 return myAddress; |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
541 } |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
542 |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
543 /** |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
544 * gzip byte arrays |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
545 * |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
546 * @param deflater |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
547 * @param inputs |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
548 * byte data[] |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
549 * @param inputIndex |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
550 * @param outputs |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
551 * byte data[] |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
552 * @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
|
553 * @throws IOException |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
554 */ |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
555 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
|
556 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
|
557 int len = 0; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
558 ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
559 while (inputIndex < inputs.size()) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
560 ByteBuffer b1 = inputs.get(inputIndex++); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
561 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
|
562 /** |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
563 * 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
|
564 * 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
|
565 * 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
|
566 * 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
|
567 * of bug of Java library. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
568 */ |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
569 if (inputIndex == inputs.size()) |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
570 deflater.finish(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
571 int len1 = 0; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
572 do { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
573 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
|
574 c1.remaining()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
575 if (len1 > 0) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
576 len += len1; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
577 c1.position(c1.position() + len1); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
578 if (c1.remaining() == 0) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
579 c1.flip(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
580 outputs.addLast(c1); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
581 c1 = multicastqueue.allocate(INFLATE_BUFSIZE); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
582 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
583 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
584 } 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
|
585 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
586 if (c1.position() != 0) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
587 c1.flip(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
588 outputs.addLast(c1); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
589 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
590 deflater.reset(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
591 return len; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
592 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
593 |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
594 /** |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
595 * gunzip byte arrays |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
596 * |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
597 * @param inflater |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
598 * @param inputs |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
599 * byte data[] |
182 | 600 * @param bytes |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
601 * byte data[] |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
602 * @return number of total bytes |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
603 * @throws IOException |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
604 */ |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
605 public int unzip(Inflater inflater, LinkedList<ByteBuffer> inputs, |
318 | 606 int inputIndex, byte[] bytes, int bufSize) { |
182 | 607 int position = 0; |
608 int limit = bytes.length; | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
609 while (inputIndex < inputs.size()) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
610 ByteBuffer input = inputs.get(inputIndex++); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
611 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
|
612 // 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
|
613 // we need this |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
614 // 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
|
615 do { |
318 | 616 int len0; |
617 try { | |
618 len0 = inflater.inflate(bytes, position, limit-position); | |
619 if (len0 > 0) { | |
620 position += len0; | |
621 if (position > limit) throw new DataFormatException(); | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
622 } |
318 | 623 } catch (DataFormatException e) { |
624 e.printStackTrace(); | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
625 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
626 } while (!inflater.needsInput()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
627 } |
182 | 628 return position; |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
629 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
630 |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
631 /** |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
632 * 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
|
633 * 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
|
634 * @param dataLen |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
635 * @param reader |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
636 * @throws TransportException |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
637 * @throws UnsupportedEncodingException |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
638 */ |
264 | 639 public void readSendData(int dataLen, Reader reader, byte[] bytes, FramebufferUpdateRectangle rect) |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
640 throws TransportException, UnsupportedEncodingException { |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
641 LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
642 ByteBuffer header = multicastqueue.allocate(16); |
242 | 643 ByteBuffer serial = multicastqueue.allocate(4+8); |
202 | 644 if (!isTreeManager()) { |
242 | 645 reader.readBytes(serial.array(),0,4+8); |
646 serial.limit(4+8); | |
182 | 647 } |
185 | 648 reader.mark(dataLen); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
649 reader.readBytes(header.array(), 0, 16); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
650 header.limit(16); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
651 if (header.get(0) == FramebufferUpdate) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
652 int encoding = header.getInt(12); |
239 | 653 |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
654 if (encoding == EncodingType.ZRLE.getId() |
229
5eb8aa65f387
fix checkdelay number-of-rectangle, and send checkdelay to lower node.
oc
parents:
227
diff
changeset
|
655 || encoding == EncodingType.ZLIB.getId()) { |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
656 // recompress into ZREE |
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
657 // 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
|
658 ByteBuffer len = multicastqueue.allocate(4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
659 reader.readBytes(len.array(), 0, 4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
660 len.limit(4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
661 ByteBuffer inputData = multicastqueue.allocate(dataLen - 20); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
662 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
|
663 inputData.limit(dataLen - 20); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
664 LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
665 inputs.add(inputData); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
666 header.putInt(12, EncodingType.ZRLEE.getId()); // means |
223 | 667 // recompress |
668 // every time | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
669 // 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
|
670 // protocol, clients have to be modified. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
671 Deflater nDeflater = deflater; // new Deflater(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
672 LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
673 try { |
182 | 674 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
|
675 // dump32(inputs); |
182 | 676 out.add(ByteBuffer.wrap(bytes)); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
677 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
|
678 ByteBuffer blen = multicastqueue.allocate(4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
679 blen.putInt(len2); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
680 blen.flip(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
681 bufs.addFirst(blen); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
682 bufs.addFirst(header); |
242 | 683 addSerialNumber(bufs); |
270 | 684 if (filterSingleDisplay) { |
275 | 685 if (rect.x < singleWidth) { |
270 | 686 multicastqueue.put(bufs); |
687 } | |
688 } else { | |
689 multicastqueue.put(bufs); | |
690 } | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
691 } catch (IOException e) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
692 throw new TransportException(e); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
693 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
694 return; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
695 } |
233 | 696 |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
697 // ZRLEE is already compressed |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
698 bufs.add(header); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
699 if (dataLen > 16) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
700 ByteBuffer b = multicastqueue.allocate(dataLen - 16); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
701 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
|
702 b.limit(dataLen - 16); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
703 bufs.add(b); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
704 } |
242 | 705 this.addSerialNumber(bufs); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
706 multicastqueue.put(bufs); |
233 | 707 |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
708 return; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
709 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
710 // 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
|
711 // decompressing here, |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
712 // 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
|
713 // each client. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
714 // 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
|
715 // here. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
716 } |
124 | 717 |
223 | 718 public void setId(short id) { |
719 this.id = id; | |
720 } | |
169 | 721 |
223 | 722 public short getId() { |
723 return id; | |
724 } | |
169 | 725 |
174 | 726 public void setMyAddress(String myHostName) { |
727 this.myAddress = myHostName; | |
223 | 728 |
174 | 729 } |
730 | |
731 public void setLeader(boolean leader) { | |
732 this.leader = leader; | |
733 } | |
734 | |
735 public boolean isLeader() { | |
736 return leader; | |
737 } | |
738 | |
203 | 739 public void setTreeManager(String intf, TreeManagement clients) { |
223 | 740 nets.setTreeManager(intf, clients); |
174 | 741 } |
223 | 742 |
203 | 743 public TreeManagement getTreeManager(String intf) { |
231 | 744 TreeManagement tm = nets.getTreeManager(intf); |
745 this.nodeList = tm.getList(); | |
746 return tm; | |
174 | 747 } |
748 | |
749 /** | |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
750 * change VNCServer is called when host change. |
174 | 751 * |
275 | 752 * @param vncProxyService |
174 | 753 * @param hostName |
754 * HostAddress | |
755 * @param width | |
756 * FrameWidth | |
757 * @param height | |
758 * FrameHeight | |
275 | 759 * @param id |
760 * @throws InterruptedException | |
174 | 761 */ |
762 public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int width, int height, short id) | |
223 | 763 throws UnknownHostException, IOException, InterruptedException { |
257 | 764 |
765 this.frameSizeWidth = width; | |
766 this.frameSizeHeight = height; | |
283 | 767 singleWidth = frameSizeWidth; |
301 | 768 singleHeight = frameSizeHeight; |
304 | 769 if (filterSingleDisplay) { |
770 // send single display width to other node. | |
771 sendSingleDisplaySize(singleWidth, singleHeight); | |
772 } | |
223 | 773 // stop reader stop |
174 | 774 stopReceiverTask(); |
192 | 775 reconnectingId = id; |
223 | 776 vncProxyService.inhelitClients(vncProxyService, hostName); |
317 | 777 // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary |
223 | 778 reconnecting = true; |
779 if (reconnectingId!=0) { | |
780 waitForVNCConnection(); | |
781 } | |
174 | 782 } |
783 | |
784 /** | |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
785 * Create send sound thread. |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
786 */ |
298 | 787 public void createSendSoundThread(TreeRFBProto rfb) throws SocketException, UnknownHostException { |
291 | 788 SendSound sendSound; |
293 | 789 // DatagramSocket socket = new DatagramSocket(selectPort(ConnectionParams.DEFAULT_RTP_PORT), InetAddress.getLocalHost()); |
291 | 790 if(rfb.isTreeManager()) { |
293 | 791 sendSound = new SendSound(socket, rfb); |
291 | 792 } else { |
292 | 793 String ip = "133.13.57.59"; |
794 String port = "60004"; | |
293 | 795 sendSound = new SendSound(socket, rfb, ip, port); |
291 | 796 } |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
797 Thread sendSoundThread = new Thread(sendSound, "send-sound"); |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
798 sendSoundThread.start(); |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
799 } |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
800 |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
801 /** |
174 | 802 * start accepting children |
803 * run rootFinderListener if necessary | |
804 */ | |
176 | 805 public void createConnectionAndStart(ViewerInterface v) { |
223 | 806 selectPort(ConnectionParams.DEFAULT_VNC_ROOT); |
176 | 807 startTreeVncCommandListener(); |
223 | 808 if(isTreeManager() && firstTime) { |
809 getCast = new TreeRootFinderListener(v); | |
239 | 810 Thread treeRootFindThread = new Thread(getCast, "tree-root-find-listener"); |
811 treeRootFindThread.start(); | |
223 | 812 firstTime = false; |
813 } | |
174 | 814 } |
815 | |
223 | 816 public void startTreeVncCommandListener() { |
176 | 817 acceptThread = new TreeVncCommandChannelListener(this, getAcceptPort()); |
223 | 818 Thread thread = new Thread(acceptThread, "TreeVNC-accept"); |
819 thread.start(); | |
176 | 820 } |
821 | |
174 | 822 public TreeVncCommandChannelListener getAcceptThread() { |
823 return acceptThread; | |
824 } | |
825 | |
176 | 826 public void setConnectionParam(CreateConnectionParam createConnectionParam) { |
827 cp = createConnectionParam; | |
828 } | |
829 | |
830 public CreateConnectionParam getConnectionParam() { | |
831 return cp; | |
832 } | |
833 | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
834 public boolean hasViewer() { |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
835 return hasViewer; |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
836 } |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
837 |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
838 public void setHasViewer(boolean b) { |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
839 hasViewer = b; |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
840 } |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
841 |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
842 public void setReconnecting(boolean b) { |
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
843 reconnecting = b; |
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
844 } |
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
845 |
223 | 846 public int getReconnectingId() { |
847 return reconnectingId; | |
848 } | |
849 | |
850 public void setShowTree(boolean showTree) { | |
240 | 851 this.showTreeNode = showTree; |
852 } | |
853 | |
854 public void setCheckDelay(boolean checkDelay) { | |
855 this.checkDelay = checkDelay; | |
223 | 856 } |
194 | 857 |
241 | 858 public void setAddSerialNum(boolean addSerialNum) { |
859 this.addSerialNum = addSerialNum; | |
860 } | |
861 | |
235 | 862 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
|
863 int nodeNum = 0; |
235 | 864 |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
865 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
|
866 TreeVNCNode tvn = (TreeVNCNode)i.next(); |
235 | 867 if (port == tvn.port && address.equals(tvn.hostname)) { |
868 nodeNum = tvn.treeNum; | |
869 return nodeNum; | |
870 } | |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
871 } |
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
872 return nodeNum; |
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
873 } |
241 | 874 |
257 | 875 public void setFixingSize(boolean fixingSize) { |
876 this.fixingSize = fixingSize; | |
256 | 877 } |
267 | 878 |
879 public void setFilterSingleDisplay(boolean filterSingleDisplay) { | |
880 this.filterSingleDisplay = filterSingleDisplay; | |
881 } | |
281 | 882 |
293 | 883 private DatagramSocket createSocket() { |
884 | |
885 try { | |
886 if (socket == null) { | |
887 this.socket = new DatagramSocket(ConnectionParams.DEFAULT_RTP_PORT, InetAddress.getLocalHost()); | |
888 } | |
889 } catch (SocketException e) { | |
890 e.printStackTrace(); | |
891 } catch (UnknownHostException e) { | |
892 e.printStackTrace(); | |
893 } | |
894 return socket; | |
895 } | |
306 | 896 |
897 public void setSingleDisplaySize(int singleWidth, int singleHeight) { | |
898 this.singleWidth = singleWidth; | |
899 this.singleHeight = singleHeight; | |
900 } | |
901 | |
902 public int getSingleWidth() { | |
903 return singleWidth; | |
904 } | |
905 | |
906 public int getSingleHeight() { | |
907 return singleHeight; | |
908 } | |
240 | 909 } |