Mercurial > hg > Members > riono > TreeVNC_ja_comment
annotate src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java @ 84:c063d32fd983
minor fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 30 Apr 2014 18:19:44 +0900 |
parents | 40d400a7ec84 |
children | 75879c316796 |
rev | line source |
---|---|
12 | 1 package jp.ac.u_ryukyu.treevnc.server; |
11 | 2 |
34 | 3 //import static org.junit.Assert.*; |
4 //import org.junit.Test; | |
11 | 5 |
6 import java.io.IOException; | |
7 import java.net.BindException; | |
8 import java.net.ServerSocket; | |
9 import java.net.Socket; | |
10 import java.nio.ByteBuffer; | |
11 import java.util.LinkedList; | |
63 | 12 |
15 | 13 import com.glavsoft.exceptions.TransportException; |
14 import com.glavsoft.rfb.encoding.EncodingType; | |
15 import com.glavsoft.transport.Reader; | |
16 | 16 import com.glavsoft.transport.Writer; |
83 | 17 |
11 | 18 import java.util.concurrent.ExecutorService; |
19 import java.util.zip.DataFormatException; | |
20 import java.util.zip.Deflater; | |
21 import java.util.zip.Inflater; | |
22 | |
32 | 23 import jp.ac.u_ryukyu.treevnc.MyRfbProto; |
12 | 24 |
28 | 25 public class MyRfbProtoProxy extends MyRfbProto { |
54 | 26 //final static String versionMsg_3_855 = "RFB 003.855\n"; |
27 final static String versionMsg_3_856 = "RFB 003.856\n"; | |
11 | 28 /** |
54 | 29 * CheckMillis is one of new msgType for RFB 3.855 and 3.856. |
11 | 30 */ |
31 final static byte SpeedCheckMillis = 4; | |
15 | 32 final static int FramebufferUpdate = 0; |
33 final static int CheckDelay = 11; | |
16 | 34 final static int FramebufferUpdateRequest = 3; |
11 | 35 |
36 // Secyrity type of OS X | |
37 final static int SecTypeReqAccess = 32; | |
38 | |
39 // Supported authentication types | |
40 final static int AuthAccess = 32; | |
41 | |
42 private static final int INFLATE_BUFSIZE = 1024 * 100; | |
43 boolean printStatusFlag = false; | |
44 long startCheckTime; | |
19 | 45 |
11 | 46 private ServerSocket servSock; |
47 protected int acceptPort; | |
48 // private byte initData[]; | |
49 private LinkedList<Socket> cliListTmp; | |
50 private LinkedList<Socket> cliList; | |
51 boolean createBimgFlag; | |
52 boolean proxyFlag = true; | |
53 ExecutorService executor; | |
54 | |
55 byte[] pngBytes; | |
56 // private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new | |
57 // MostRecentMultiCast<LinkedList<ByteBuffer>>(10); | |
45 | 58 // private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new |
59 // MulticastQueue<LinkedList<ByteBuffer>>(); | |
11 | 60 private Inflater inflater = new Inflater(); |
61 private Deflater deflater = new Deflater(); | |
62 // private Thread requestThread; | |
63 private RequestScreenThread rThread; | |
64 private Thread requestThread; | |
63 | 65 private int rangeX = 256; // screenRange XPosition |
66 private int rangeY = 256; // screenRange YPosition | |
84 | 67 // private int rangeWidth = 512; // screenRange Width |
63 | 68 private int rangeHeight = 256; // screenRange Height |
66 | 69 private int counter = 0; // add serialnum. |
63 | 70 |
15 | 71 public MyRfbProtoProxy() { |
16 | 72 rThread = new RequestScreenThread(this); |
73 requestThread = new Thread(rThread); | |
11 | 74 } |
75 | |
19 | 76 public void setStream(Writer _writer) { |
45 | 77 // os = _writer; |
15 | 78 } |
11 | 79 |
80 void initServSock(int port) throws IOException { | |
81 servSock = new ServerSocket(port); | |
82 acceptPort = port; | |
83 } | |
84 | |
85 /* | |
86 * default port number is 5999. | |
87 */ | |
38 | 88 public int selectPort(int p) { |
11 | 89 if (servSock != null) |
38 | 90 return 0; |
11 | 91 int port = p; |
92 while (true) { | |
93 try { | |
94 initServSock(port); | |
95 break; | |
96 } catch (BindException e) { | |
97 port++; | |
98 continue; | |
99 } catch (IOException e) { | |
100 | |
101 } | |
102 } | |
103 System.out.println("accept port = " + port); | |
38 | 104 return port; |
11 | 105 } |
106 | |
60 | 107 public int getAcceptPort() { |
11 | 108 return acceptPort; |
109 } | |
110 | |
111 void setSoTimeout(int num) throws IOException { | |
112 servSock.setSoTimeout(num); | |
113 } | |
114 | |
115 public Socket accept() throws IOException { | |
116 return servSock.accept(); | |
117 } | |
45 | 118 |
40 | 119 public void socketClose() throws IOException { |
120 servSock.close(); | |
121 } | |
11 | 122 |
123 void addSock(Socket sock) { | |
124 cliList.add(sock); | |
125 } | |
126 | |
127 void addSockTmp(Socket sock) { | |
128 System.out.println("connected " + sock.getInetAddress()); | |
129 cliListTmp.add(sock); | |
130 } | |
131 | |
132 synchronized void changeStatusFlag() { | |
133 printStatusFlag = true; | |
134 } | |
135 | |
136 void printMills() { | |
137 if (printStatusFlag) { | |
138 | |
139 changeStatusFlag(); | |
140 } else { | |
141 changeStatusFlag(); | |
142 } | |
143 } | |
144 | |
145 void requestThreadStart() { | |
146 requestThread.start(); | |
147 } | |
148 | |
149 public synchronized void requestThreadNotify() { | |
150 rThread.reStart(); | |
151 } | |
152 | |
153 /** | |
154 * gzip byte arrays | |
155 * | |
156 * @param deflater | |
157 * @param inputs | |
158 * byte data[] | |
159 * @param inputIndex | |
160 * @param outputs | |
161 * byte data[] | |
162 * @return byte length in last byte array | |
163 * @throws IOException | |
164 */ | |
165 public int zip(Deflater deflater, LinkedList<ByteBuffer> inputs, | |
166 int inputIndex, LinkedList<ByteBuffer> outputs) throws IOException { | |
167 int len = 0; | |
74 | 168 ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE); |
11 | 169 while (inputIndex < inputs.size()) { |
170 ByteBuffer b1 = inputs.get(inputIndex++); | |
171 deflater.setInput(b1.array(), b1.position(), b1.remaining()); | |
172 /** | |
173 * If we finish() stream and reset() it, Deflater start new gzip | |
174 * stream, this makes continuous zlib reader unhappy. if we remove | |
175 * finish(), Deflater.deflate() never flushes its output. The | |
176 * original zlib deflate has flush flag. I'm pretty sure this a kind | |
177 * of bug of Java library. | |
178 */ | |
179 if (inputIndex == inputs.size()) | |
180 deflater.finish(); | |
181 int len1 = 0; | |
182 do { | |
183 len1 = deflater.deflate(c1.array(), c1.position(), | |
184 c1.remaining()); | |
185 if (len1 > 0) { | |
186 len += len1; | |
187 c1.position(c1.position() + len1); | |
188 if (c1.remaining() == 0) { | |
189 c1.flip(); | |
190 outputs.addLast(c1); | |
74 | 191 c1 = multicastqueue.allocate(INFLATE_BUFSIZE); |
11 | 192 } |
193 } | |
194 } while (len1 > 0 || !deflater.needsInput()); // &&!deflater.finished()); | |
195 } | |
196 if (c1.position() != 0) { | |
197 c1.flip(); | |
198 outputs.addLast(c1); | |
199 } | |
200 deflater.reset(); | |
201 return len; | |
202 } | |
203 | |
204 /** | |
205 * gunzip byte arrays | |
206 * | |
207 * @param inflater | |
208 * @param inputs | |
209 * byte data[] | |
210 * @param outputs | |
211 * byte data[] | |
212 * @return number of total bytes | |
213 * @throws IOException | |
214 */ | |
215 public int unzip(Inflater inflater, LinkedList<ByteBuffer> inputs, | |
216 int inputIndex, LinkedList<ByteBuffer> outputs, int bufSize) | |
217 throws DataFormatException { | |
218 int len = 0; | |
74 | 219 ByteBuffer buf = multicastqueue.allocate(bufSize); |
11 | 220 while (inputIndex < inputs.size()) { |
221 ByteBuffer input = inputs.get(inputIndex++); | |
222 inflater.setInput(input.array(), input.position(), input.limit()); | |
223 // if (inputIndex==inputs.size()) if inflater/deflater has symmetry, | |
224 // we need this | |
225 // inflater.end(); but this won't work | |
226 do { | |
227 int len0 = inflater.inflate(buf.array(), buf.position(), | |
228 buf.remaining()); | |
229 if (len0 > 0) { | |
230 buf.position(buf.position() + len0); | |
231 len += len0; | |
232 if (buf.remaining() == 0) { | |
233 buf.flip(); | |
234 outputs.addLast(buf); | |
74 | 235 buf = multicastqueue.allocate(bufSize); |
11 | 236 } |
237 } | |
238 } while (!inflater.needsInput()); | |
239 } | |
240 if (buf.position() != 0) { | |
241 buf.flip(); | |
242 outputs.addLast(buf); | |
243 } | |
244 return len; | |
245 } | |
246 | |
247 float maxMag = 1; | |
248 | |
249 /** | |
250 * send data to clients | |
251 * | |
252 * @param dataLen | |
45 | 253 * @param is |
11 | 254 * @throws IOException |
255 * @throws DataFormatException | |
256 * | |
257 * Zlibed packet is compressed in context dependent way, that | |
258 * is, it have to send from the beginning. But this is | |
259 * impossible. So we have to compress it again for each clients. | |
260 * Separate deflater for each clients is necessary. | |
261 * | |
262 * Java's deflater does not support flush. This means to get the | |
263 * result, we have to finish the compression. Reseting start new | |
264 * compression, but it is not accepted well in zlib continuous | |
265 * reading. So we need new Encoding ZRLEE which reset decoder | |
266 * for each packet. ZRLEE can be invisible from user, but it | |
267 * have to be implemented in the clients. ZRLEE compression is | |
268 * not context dependent, so no recompression is necessary. | |
16 | 269 * @throws TransportException |
11 | 270 */ |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
23
diff
changeset
|
271 public void readSendData(int dataLen, Reader is) throws TransportException { |
11 | 272 LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); |
74 | 273 ByteBuffer header = multicastqueue.allocate(16); |
17 | 274 is.readBytes(header.array(), 0, 16); |
11 | 275 header.limit(16); |
16 | 276 if (header.get(0) == FramebufferUpdate) { |
11 | 277 int encoding = header.getInt(12); |
15 | 278 if (encoding == EncodingType.ZRLE.getId() |
16 | 279 || encoding == EncodingType.ZLIB.getId()) { // ZRLEE is |
280 // already | |
281 // recompressed | |
74 | 282 ByteBuffer len = multicastqueue.allocate(4); |
17 | 283 is.readBytes(len.array(), 0, 4); |
11 | 284 len.limit(4); |
74 | 285 ByteBuffer inputData = multicastqueue.allocate(dataLen - 20); |
11 | 286 |
17 | 287 is.readBytes(inputData.array(), 0, inputData.capacity()); |
16 | 288 // System.out.println(dataLen); |
11 | 289 inputData.limit(dataLen - 20); |
290 | |
291 LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>(); | |
292 inputs.add(inputData); | |
293 | |
16 | 294 header.putInt(12, EncodingType.ZRLEE.getId()); // means |
295 // recompress | |
296 // every time | |
11 | 297 // using new Deflecter every time is incompatible with the |
298 // protocol, clients have to be modified. | |
299 Deflater nDeflater = deflater; // new Deflater(); | |
300 LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); | |
63 | 301 //List<ByteBuffer> out = java.util.Collections.synchronizedList(new LinkedList<ByteBuffer>()); |
19 | 302 int len2 = 0; |
303 try { | |
304 unzip(inflater, inputs, 0, out, INFLATE_BUFSIZE); | |
305 len2 = zip(nDeflater, out, 0, bufs); | |
74 | 306 out = null; |
307 multicastqueue.heapAvailable(); | |
19 | 308 } catch (DataFormatException e) { |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
23
diff
changeset
|
309 throw new TransportException(e); |
19 | 310 } catch (IOException e) { |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
23
diff
changeset
|
311 throw new TransportException(e); |
19 | 312 } |
74 | 313 |
314 ByteBuffer blen = multicastqueue.allocate(4); | |
11 | 315 blen.putInt(len2); |
316 blen.flip(); | |
63 | 317 bufs.addFirst(blen); |
11 | 318 bufs.addFirst(header); |
66 | 319 |
68 | 320 |
74 | 321 ByteBuffer serialNum = multicastqueue.allocate(8); |
66 | 322 serialNum.putLong(counter++); |
323 serialNum.flip(); | |
324 bufs.addFirst(serialNum); | |
68 | 325 |
65 | 326 multicastqueue.put(bufs); |
74 | 327 |
11 | 328 return; |
329 } | |
330 bufs.add(header); | |
331 if (dataLen > 16) { | |
74 | 332 ByteBuffer b = multicastqueue.allocate(dataLen - 16); |
17 | 333 is.readBytes(b.array(), 0, dataLen - 16); |
11 | 334 b.limit(dataLen - 16); |
335 bufs.add(b); | |
336 } | |
337 multicastqueue.put(bufs); | |
338 // is.reset(); | |
339 return; | |
340 } | |
17 | 341 is.reset(); |
11 | 342 |
343 // It may be compressed. We can inflate here to avoid repeating clients | |
344 // decompressing here, | |
345 // but it may generate too many large data. It is better to do it in | |
346 // each client. | |
347 // But we have do inflation for all input data, so we have to do it | |
348 // here. | |
349 } | |
350 | |
351 public void dump32(LinkedList<ByteBuffer> bufs) { | |
352 int len = 0; | |
353 for (ByteBuffer b : bufs) | |
354 len += b.remaining(); | |
355 ByteBuffer top = bufs.getFirst(); | |
356 ByteBuffer end = bufs.getLast(); | |
357 System.err.println("length: " + len); | |
358 System.err.print("head 0: "); | |
359 for (int i = 0; i < 16 && i < top.remaining(); i++) { | |
360 System.err.print(" " + top.get(i)); | |
361 } | |
362 System.err.print("tail 0: "); | |
363 for (int i = 0; i < 16 && i < end.remaining(); i++) { | |
364 System.err.print(" " + end.get(i)); | |
365 } | |
366 System.err.println(); | |
367 } | |
368 | |
34 | 369 /* |
45 | 370 * @Test public void test1() { try { LinkedList<ByteBuffer> in = new |
371 * LinkedList<ByteBuffer>(); LinkedList<ByteBuffer> out = new | |
372 * LinkedList<ByteBuffer>(); LinkedList<ByteBuffer> out2 = new | |
373 * LinkedList<ByteBuffer>(); // if (false) { // for(int i=0;i<10;i++) { // | |
374 * in.add(ByteBuffer.wrap("test1".getBytes())); // | |
375 * in.add(ByteBuffer.wrap("test2".getBytes())); // | |
376 * in.add(ByteBuffer.wrap("test3".getBytes())); // | |
377 * in.add(ByteBuffer.wrap("test44".getBytes())); // } // } else { String t = | |
378 * ""; for (int i = 0; i < 10; i++) { t += "test1"; t += "test2"; t += | |
379 * "test3"; t += "test44"; } in.add(ByteBuffer.wrap(t.getBytes())); } | |
380 * | |
381 * LinkedList<ByteBuffer> in1 = clone(in); | |
382 * | |
383 * Deflater deflater = new Deflater(); zip(deflater, in, 0, out); // | |
384 * LinkedList<ByteBuffer> out3 = clone(out); zipped result is depend // on | |
385 * deflator's state unzip(inflater, out, 0, out2, INFLATE_BUFSIZE); // | |
386 * inflater.reset(); equalByteBuffers(in1, out2); LinkedList<ByteBuffer> | |
387 * out4 = new LinkedList<ByteBuffer>(); deflater = new Deflater(); | |
388 * zip(deflater, out2, 0, out4); LinkedList<ByteBuffer> out5 = new | |
389 * LinkedList<ByteBuffer>(); unzip(inflater, out4, 0, out5, | |
390 * INFLATE_BUFSIZE); int len = equalByteBuffers(in1, out5); | |
391 * | |
392 * System.out.println("Test Ok. " + len); } catch (Exception e) { | |
393 * assertEquals(0, 1); } } | |
394 */ | |
11 | 395 |
45 | 396 /* |
397 * public int equalByteBuffers(LinkedList<ByteBuffer> in, | |
398 * LinkedList<ByteBuffer> out2) { int len = 0; Iterable<Byte> i = | |
399 * byteBufferIterator(in); Iterator<Byte> o = | |
400 * byteBufferIterator(out2).iterator(); | |
401 * | |
402 * for (int b : i) { len++; if (o.hasNext()) { int c = o.next(); | |
403 * assertEquals(b, c); } else assertEquals(0, 1); } if (o.hasNext()) | |
404 * assertEquals(0, 1); // System.out.println(); return len; } | |
34 | 405 */ |
16 | 406 |
17 | 407 void sendRfbVersion(Writer writer) throws IOException, TransportException { |
15 | 408 // os.write(versionMsg_3_8.getBytes()); |
54 | 409 writer.write(versionMsg_3_856.getBytes()); |
15 | 410 } |
16 | 411 |
45 | 412 int readVersionMsg(Reader reader, Writer writer) throws IOException, |
413 TransportException { | |
11 | 414 |
15 | 415 byte[] b = new byte[12]; |
416 | |
17 | 417 reader.readBytes(b); |
15 | 418 |
419 if ((b[0] != 'R') || (b[1] != 'F') || (b[2] != 'B') || (b[3] != ' ') | |
420 || (b[4] < '0') || (b[4] > '9') || (b[5] < '0') || (b[5] > '9') | |
421 || (b[6] < '0') || (b[6] > '9') || (b[7] != '.') | |
422 || (b[8] < '0') || (b[8] > '9') || (b[9] < '0') || (b[9] > '9') | |
423 || (b[10] < '0') || (b[10] > '9') || (b[11] != '\n')) { | |
424 throw new IOException("this is not an RFB server"); | |
425 } | |
426 | |
427 int rfbMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0'); | |
428 int rfbMinor = (b[8] - '0') * 100 + (b[9] - '0') * 10 + (b[10] - '0'); | |
429 | |
430 if (rfbMajor < 3) { | |
431 throw new IOException( | |
432 "RFB server does not support protocol version 3"); | |
433 } | |
434 | |
435 if (rfbMinor == 855) { | |
17 | 436 sendProxyFlag(writer); |
15 | 437 if (proxyFlag) |
17 | 438 sendPortNumber(writer); |
15 | 439 } |
440 return rfbMinor; | |
441 } | |
16 | 442 |
17 | 443 void sendProxyFlag(Writer writer) throws TransportException { |
15 | 444 if (proxyFlag) |
17 | 445 writer.writeInt(1); |
15 | 446 else |
17 | 447 writer.writeInt(0); |
15 | 448 } |
16 | 449 |
17 | 450 void sendPortNumber(Writer writer) throws TransportException { |
15 | 451 byte[] b = new byte[4]; |
45 | 452 // b = castIntByte(getHost.getPort()); |
17 | 453 b = castIntByte(9999); |
454 writer.write(b); | |
15 | 455 } |
456 | |
17 | 457 void sendSecurityType(Writer os) throws TransportException { |
15 | 458 // number-of-security-types |
17 | 459 os.writeInt(1); |
15 | 460 // security-types |
461 // 1:None | |
17 | 462 os.writeInt(1); |
15 | 463 |
464 /* | |
465 * os.write(4); os.write(30); os.write(31); os.write(32); os.write(35); | |
466 * os.flush(); | |
467 */ | |
468 } | |
469 | |
17 | 470 void readSecType(Reader reader) throws TransportException { |
15 | 471 byte[] b = new byte[1]; |
17 | 472 reader.read(b); |
15 | 473 } |
474 | |
17 | 475 void readSecType(Reader is, Writer os) throws TransportException { |
15 | 476 byte[] b = new byte[1]; |
17 | 477 is.readBytes(b); |
15 | 478 |
479 int count = 260; | |
480 int[] data = { 0, 2, 0, -128, -1, -1, -1, -1, -1, -1, -1, -1, -55, 15, | |
481 -38, -94, 33, 104, -62, 52, -60, -58, 98, -117, -128, -36, 28, | |
482 -47, 41, 2, 78, 8, -118, 103, -52, 116, 2, 11, -66, -90, 59, | |
483 19, -101, 34, 81, 74, 8, 121, -114, 52, 4, -35, -17, -107, 25, | |
484 -77, -51, 58, 67, 27, 48, 43, 10, 109, -14, 95, 20, 55, 79, | |
485 -31, 53, 109, 109, 81, -62, 69, -28, -123, -75, 118, 98, 94, | |
486 126, -58, -12, 76, 66, -23, -90, 55, -19, 107, 11, -1, 92, -74, | |
487 -12, 6, -73, -19, -18, 56, 107, -5, 90, -119, -97, -91, -82, | |
488 -97, 36, 17, 124, 75, 31, -26, 73, 40, 102, 81, -20, -26, 83, | |
489 -127, -1, -1, -1, -1, -1, -1, -1, -1, -111, 73, -29, 30, 57, | |
490 -67, -75, -77, -49, -50, -99, -76, -80, -80, 14, 65, 57, -105, | |
491 -103, -54, -102, 3, 39, -44, 39, 35, 118, -84, -64, 37, -117, | |
492 -21, 89, -31, -68, 70, 5, 122, -92, -119, 9, 121, 63, -112, | |
493 -60, 122, -46, -69, -36, 92, -103, -92, 74, 92, -73, 87, 120, | |
494 -8, 116, -47, 111, 20, -41, 110, 122, -3, -94, 14, 42, -51, | |
495 -59, 48, -54, -125, 117, 60, 77, -52, -31, 98, 32, -2, -102, | |
496 -15, -29, 58, -14, -106, -116, -32, -86, 50, -32, -16, -3, | |
497 -123, 87, 88, -118, 10, 120, -107, -37, 125, -110, 59, 87, 93, | |
498 -24, 124, -99, 18, 78, -13, -49, -34, -24, -27, 1, 114, -67, | |
499 -98, -56, -3, 85, -67, -126, 77 }; | |
500 for (int i = 0; i < count; i++) { | |
501 os.write((byte) data[i]); | |
502 os.flush(); | |
503 } | |
504 | |
505 byte[] c = new byte[256]; | |
17 | 506 is.readBytes(c); |
15 | 507 |
508 System.out.println(new String(c)); | |
509 | |
510 } | |
511 | |
17 | 512 void sendSecResult(Writer os) throws TransportException { |
15 | 513 byte[] b = castIntByte(0); |
514 os.write(b); | |
515 } | |
16 | 516 |
15 | 517 byte[] castIntByte(int len) { |
518 byte[] b = new byte[4]; | |
519 b[0] = (byte) ((len >>> 24) & 0xFF); | |
520 b[1] = (byte) ((len >>> 16) & 0xFF); | |
521 b[2] = (byte) ((len >>> 8) & 0xFF); | |
522 b[3] = (byte) ((len >>> 0) & 0xFF); | |
523 return b; | |
524 } | |
525 | |
17 | 526 void readClientInit(Reader in) throws TransportException { |
15 | 527 byte[] b = new byte[0]; |
17 | 528 in.readBytes(b); |
15 | 529 } |
61
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
530 |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
531 @Override |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
532 public boolean getReadyReconnect() { |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
533 return readyReconnect; |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
534 } |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
535 |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
536 @Override |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
537 public void setReadyReconnect(boolean ready) { |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
538 readyReconnect = ready; |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
539 } |
63 | 540 |
541 /* | |
542 int a = list.size(); | |
543 for(int i = 0; i < a -1; i++ ) { | |
544 if(i>6) { | |
545 if(i==7){ | |
546 list.get(7).limit(20540); | |
547 } | |
548 list.remove(8); | |
549 } | |
550 } | |
551 */ | |
552 | |
83 | 553 @SuppressWarnings("unused") |
554 private void testScreenSize(LinkedList<ByteBuffer> list, ByteBuffer header) { | |
63 | 555 int block = (64*64*3)+1; // size of one-block. |
556 int skip; // skip-byte | |
557 int xBlock = (header.getShort(8)-header.getShort(4))/64; //xBlockNum | |
558 int yBlock = (header.getShort(10)-header.getShort(6))/64; // yBlockNum; | |
559 int outOfRangeT = (rangeY - header.getShort(6))/64 > 0 ? (rangeY - header.getShort(6))/64 : 0; | |
560 int outOfRangeB = (header.getShort(6) + header.getShort(10))-(rangeY + rangeHeight)/64 > 0 ? | |
561 (header.getShort(6) + header.getShort(10))-(rangeY + rangeHeight)/64 : 0; | |
562 int outOfRangeL = (rangeX - header.getShort(4))/64 > 0 ? (rangeY - header.getShort(4))/64 : 0; | |
563 int outOfRangeR = (header.getShort(4) + header.getShort(8))-(rangeY + rangeHeight)/64 > 0 ? | |
564 (header.getShort(4) + header.getShort(8))-(rangeY + rangeHeight)/64 : 0; | |
565 ByteBuffer input = list.getFirst(); | |
566 if((header.getShort(8)-header.getShort(4)%64)!=0) | |
567 ++xBlock; | |
568 if((header.getShort(10)-header.getShort(6)%64)!=0) | |
569 ++yBlock; | |
570 | |
571 for(int i=0; i<yBlock; i++) { | |
572 for(int g=0; g<xBlock; g++) { | |
573 if(outOfRangeT < i && i < yBlock - outOfRangeB) { | |
574 input.get(block); | |
575 } | |
576 } | |
577 } | |
578 if((rangeX-header.getShort(4))%64==0) | |
579 skip = 4*block*(header.getShort(8)/64); | |
580 else | |
581 skip = (4*block*(header.getShort(8)/64))+1; | |
582 | |
45 | 583 |
63 | 584 } |
585 | |
83 | 586 @SuppressWarnings("unused") |
587 private void createHeader(ByteBuffer buf) { | |
63 | 588 buf.putShort(4, (short)256); |
589 buf.putShort(6, (short)256); | |
590 buf.putShort(8, (short)512); | |
591 buf.putShort(10, (short)256); | |
592 } | |
66 | 593 |
11 | 594 } |
63 | 595 |