Mercurial > hg > Members > nobuyasu > tightVNCProxy
comparison src/myVncProxy/MyRfbProto.java @ 65:5fca2bb52dc7
create checkMillis
author | e085711 |
---|---|
date | Fri, 22 Jul 2011 03:21:56 +0900 |
parents | 7795e2b5d3ef |
children | 7632606406cb |
comparison
equal
deleted
inserted
replaced
63:4864a7d1df00 | 65:5fca2bb52dc7 |
---|---|
22 import java.util.concurrent.ExecutorService; | 22 import java.util.concurrent.ExecutorService; |
23 import java.util.concurrent.Executors; | 23 import java.util.concurrent.Executors; |
24 import java.io.OutputStream; | 24 import java.io.OutputStream; |
25 | 25 |
26 class MyRfbProto extends RfbProto { | 26 class MyRfbProto extends RfbProto { |
27 | |
28 final static String versionMsg_3_998 = "RFB 003.998\n"; | 27 final static String versionMsg_3_998 = "RFB 003.998\n"; |
28 /** | |
29 * CheckMillis is one of new msgType for RFB 3.998. | |
30 */ | |
31 final static int CheckMillis = 4; | |
32 boolean printStatusFlag = false; | |
33 long startCheckTime; | |
29 | 34 |
30 private int messageType; | 35 private int messageType; |
31 private int rectangles; | 36 private int rectangles; |
32 private int rectX; | 37 private int rectX; |
33 private int rectY; | 38 private int rectY; |
337 dataLen = 1000000; | 342 dataLen = 1000000; |
338 mark(dataLen); | 343 mark(dataLen); |
339 } | 344 } |
340 return dataLen; | 345 return dataLen; |
341 } | 346 } |
347 | |
342 void readSendData(int dataLen) throws IOException { | 348 void readSendData(int dataLen) throws IOException { |
343 byte buffer[] = new byte[dataLen]; | 349 byte buffer[] = new byte[dataLen]; |
344 readFully(buffer); | 350 readFully(buffer); |
345 multicastqueue.put(buffer); | 351 multicastqueue.put(buffer); |
346 reset(); | 352 reset(); |
353 | |
347 /* | 354 /* |
348 for (Socket cli : cliList) { | 355 for (Socket cli : cliList) { |
349 try { | 356 try { |
350 OutputStream out = cli.getOutputStream(); | 357 OutputStream out = cli.getOutputStream(); |
351 executor.execute(new SendThread(out, buffer)); | 358 executor.execute(new SendThread(out, buffer)); |
412 | 419 |
413 BufferedImage createBimg() throws IOException { | 420 BufferedImage createBimg() throws IOException { |
414 BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(pngBytes)); | 421 BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(pngBytes)); |
415 return bimg; | 422 return bimg; |
416 } | 423 } |
417 | 424 /* |
418 void readPngData() throws IOException { | 425 void readPngData() throws IOException { |
419 pngBytes = new byte[is.available()]; | 426 pngBytes = new byte[is.available()]; |
420 readFully(pngBytes); | 427 readFully(pngBytes); |
421 } | 428 } |
422 | 429 */ |
423 void printFramebufferUpdate() { | 430 void printFramebufferUpdate() { |
424 | 431 |
425 System.out.println("messageType=" + messageType); | 432 System.out.println("messageType=" + messageType); |
426 System.out.println("rectangles=" + rectangles); | 433 System.out.println("rectangles=" + rectangles); |
427 System.out.println("encoding=" + encoding); | 434 System.out.println("encoding=" + encoding); |
431 + 16); | 438 + 16); |
432 break; | 439 break; |
433 default: | 440 default: |
434 } | 441 } |
435 } | 442 } |
443 | |
444 void readCheckMillis() throws IOException { | |
445 byte[] b = new byte[4]; | |
446 readFully(b); | |
447 } | |
448 | |
449 void startCheckMills() { | |
450 byte[] b = new byte[4]; | |
451 b = castIntByte(4); | |
452 startCheckTime = System.currentTimeMillis(); | |
453 multicastqueue.put(b); | |
454 } | |
455 | |
456 void endCheckMills() { | |
457 long accTime = System.currentTimeMillis(); | |
458 long time = accTime - startCheckTime; | |
459 System.out.println("checkMillis: " + time); | |
460 } | |
461 | |
462 void printStatus() { | |
463 System.out.println(); | |
464 } | |
465 | |
466 synchronized void changeStatusFlag() { | |
467 printStatusFlag = true; | |
468 } | |
469 | |
470 void printMills() { | |
471 if(printStatusFlag) { | |
472 | |
473 changeStatusFlag(); | |
474 } else { | |
475 changeStatusFlag(); | |
476 } | |
477 } | |
478 | |
436 | 479 |
437 void newClient(acceptThread acceptThread, final Socket newCli, | 480 void newClient(acceptThread acceptThread, final Socket newCli, |
438 final OutputStream os, final InputStream is) throws IOException { | 481 final OutputStream os, final InputStream is) throws IOException { |
439 // createBimgFlag = true; | 482 // createBimgFlag = true; |
440 // rfb.addSockTmp(newCli); | 483 // rfb.addSockTmp(newCli); |
441 // addSock(newCli); | 484 // addSock(newCli); |
442 final Client<byte[]> c = multicastqueue.newClient(); | 485 final Client<byte[]> c = multicastqueue.newClient(); |
443 Runnable sender = new Runnable() { | 486 Runnable sender = new Runnable() { |
444 public void run() { | 487 public void run() { |
445 try { | 488 try { |
446 // 初期接続確立の部分 | 489 /** |
490 * initial connection of RFB protocol | |
491 */ | |
447 sendRfbVersion(os); | 492 sendRfbVersion(os); |
448 readVersionMsg(is); | 493 readVersionMsg(is); |
449 sendSecurityType(os); | 494 sendSecurityType(os); |
450 readSecType(is); | 495 readSecType(is); |
451 sendSecResult(os); | 496 sendSecResult(os); |
455 for (;;) { | 500 for (;;) { |
456 byte[] b = c.poll(); | 501 byte[] b = c.poll(); |
457 os.write(b, 0, b.length); | 502 os.write(b, 0, b.length); |
458 } | 503 } |
459 } catch (IOException e) { | 504 } catch (IOException e) { |
460 //接続が切れた処理 | 505 /** |
461 //lockしないと駄目 | 506 * if socket closed |
507 */ | |
462 // cliList.remove(newCli); | 508 // cliList.remove(newCli); |
463 } | 509 } |
464 | 510 |
465 } | 511 } |
466 | 512 |