# HG changeset patch # User e085711 # Date 1311272516 -32400 # Node ID 5fca2bb52dc77b387d5ee61877b25e8e9471c264 # Parent 4864a7d1df003a7c987c1bb50bbb0814383efe6d create checkMillis diff -r 4864a7d1df00 -r 5fca2bb52dc7 src/myVncProxy/MyRfbProto.java --- a/src/myVncProxy/MyRfbProto.java Tue Jul 12 13:47:32 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Fri Jul 22 03:21:56 2011 +0900 @@ -24,8 +24,13 @@ import java.io.OutputStream; class MyRfbProto extends RfbProto { - final static String versionMsg_3_998 = "RFB 003.998\n"; + /** + * CheckMillis is one of new msgType for RFB 3.998. + */ + final static int CheckMillis = 4; + boolean printStatusFlag = false; + long startCheckTime; private int messageType; private int rectangles; @@ -339,11 +344,13 @@ } return dataLen; } + void readSendData(int dataLen) throws IOException { byte buffer[] = new byte[dataLen]; readFully(buffer); multicastqueue.put(buffer); reset(); + /* for (Socket cli : cliList) { try { @@ -414,12 +421,12 @@ BufferedImage bimg = ImageIO.read(new ByteArrayInputStream(pngBytes)); return bimg; } - +/* void readPngData() throws IOException { pngBytes = new byte[is.available()]; readFully(pngBytes); } - +*/ void printFramebufferUpdate() { System.out.println("messageType=" + messageType); @@ -433,6 +440,42 @@ default: } } + + void readCheckMillis() throws IOException { + byte[] b = new byte[4]; + readFully(b); + } + + void startCheckMills() { + byte[] b = new byte[4]; + b = castIntByte(4); + startCheckTime = System.currentTimeMillis(); + multicastqueue.put(b); + } + + void endCheckMills() { + long accTime = System.currentTimeMillis(); + long time = accTime - startCheckTime; + System.out.println("checkMillis: " + time); + } + + void printStatus() { + System.out.println(); + } + + synchronized void changeStatusFlag() { + printStatusFlag = true; + } + + void printMills() { + if(printStatusFlag) { + + changeStatusFlag(); + } else { + changeStatusFlag(); + } + } + void newClient(acceptThread acceptThread, final Socket newCli, final OutputStream os, final InputStream is) throws IOException { @@ -443,7 +486,9 @@ Runnable sender = new Runnable() { public void run() { try { - // 初期接続確立の部分 + /** + * initial connection of RFB protocol + */ sendRfbVersion(os); readVersionMsg(is); sendSecurityType(os); @@ -457,8 +502,9 @@ os.write(b, 0, b.length); } } catch (IOException e) { - //接続が切れた処理 - //lockしないと駄目 + /** + * if socket closed + */ // cliList.remove(newCli); } diff -r 4864a7d1df00 -r 5fca2bb52dc7 src/myVncProxy/ProxyVncCanvas.java --- a/src/myVncProxy/ProxyVncCanvas.java Tue Jul 12 13:47:32 2011 +0900 +++ b/src/myVncProxy/ProxyVncCanvas.java Fri Jul 22 03:21:56 2011 +0900 @@ -360,18 +360,14 @@ // main dispatch loop // - - - long count = 0; while (true) { // System.out.println("\ncount=" + count); count++; - /* + /** * read Data from parents and send Data to Client. - * */ rfb.sendDataToClient(); @@ -382,6 +378,10 @@ // Process the message depending on its type. switch (msgType) { + case MyRfbProto.CheckMillis: + rfb.readCheckMillis(); + + break; case RfbProto.FramebufferUpdate: if (statNumUpdates == viewer.debugStatsExcludeUpdates @@ -504,7 +504,7 @@ setPixelFormat(); fullUpdateNeeded = true; } -*/ +*/ // Request framebuffer update if needed. int w = rfb.framebufferWidth; diff -r 4864a7d1df00 -r 5fca2bb52dc7 src/myVncProxy/VncProxyService.java --- a/src/myVncProxy/VncProxyService.java Tue Jul 12 13:47:32 2011 +0900 +++ b/src/myVncProxy/VncProxyService.java Fri Jul 22 03:21:56 2011 +0900 @@ -15,7 +15,6 @@ v.init(); v.start_threads(); - } String[] mainArgs; @@ -293,8 +292,8 @@ System.out.println("Desktop size is " + rfb.framebufferWidth + " x " + rfb.framebufferHeight); - setEncodings(); - +// setEncodings(); + autoSelectEncodings(); //showConnectionStatus(null); } diff -r 4864a7d1df00 -r 5fca2bb52dc7 src/myVncProxy/acceptThread.java --- a/src/myVncProxy/acceptThread.java Tue Jul 12 13:47:32 2011 +0900 +++ b/src/myVncProxy/acceptThread.java Fri Jul 22 03:21:56 2011 +0900 @@ -1,5 +1,5 @@ package myVncProxy; -import java.net.ServerSocket; + import java.net.Socket; import java.io.IOException; import java.io.InputStream; @@ -9,23 +9,23 @@ MyRfbProto rfb; byte[] imageBytes; - acceptThread(MyRfbProto _rfb ) { + acceptThread(MyRfbProto _rfb) { rfb = _rfb; } + public void run() { rfb.selectPort(); while (true) { try { Socket newCli = rfb.accept(); - + OutputStream os = newCli.getOutputStream(); InputStream is = newCli.getInputStream(); rfb.newClient(this, newCli, os, is); - } catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); System.out.println(e); } } } } -