# HG changeset patch # User Tatsuki IHA # Date 1448299131 -32400 # Node ID 3af5f4af2d63151710e11bbfcfc3e33edaf221f9 # Parent 1228677ca8884cbe224b6f70cb1642332d1f6d16 Send data size for checkDelay diff -r 1228677ca888 -r 3af5f4af2d63 .idea/gradle.xml --- a/.idea/gradle.xml Thu Nov 19 17:18:23 2015 +0900 +++ b/.idea/gradle.xml Tue Nov 24 02:18:51 2015 +0900 @@ -11,6 +11,11 @@ + diff -r 1228677ca888 -r 3af5f4af2d63 .idea/workspace.xml --- a/.idea/workspace.xml Thu Nov 19 17:18:23 2015 +0900 +++ b/.idea/workspace.xml Tue Nov 24 02:18:51 2015 +0900 @@ -2,8 +2,12 @@ - + + + + + @@ -20,9 +24,6 @@ - - - @@ -40,16 +41,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + @@ -57,29 +77,22 @@ - + - - - - - - - - - - - + - + + + + @@ -87,74 +100,37 @@ - - + + + + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + @@ -163,18 +139,8 @@ - - - - - - - - - - - - + + @@ -183,8 +149,30 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -192,13 +180,38 @@ - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + @@ -207,48 +220,23 @@ - - - - - - - - - - - - - - - + + - - + + - - + + - - - - - - - - - - - - @@ -531,8 +519,6 @@ - @@ -597,10 +586,10 @@ + + - - @@ -916,6 +905,8 @@ + + @@ -935,7 +926,7 @@ - + @@ -992,6 +983,35 @@ + + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1342,13 +1396,13 @@ file://$PROJECT_DIR$/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java - 401 + 404 file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 526 + 527 @@ -1456,13 +1510,13 @@ file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 931 + 945 file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 951 + 965 @@ -1516,13 +1570,13 @@ file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 935 + 949 file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 492 + 493 @@ -1534,7 +1588,7 @@ file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 962 + 976 @@ -1552,13 +1606,13 @@ file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 323 + 324 file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 802 + 816 @@ -1594,7 +1648,7 @@ file://$PROJECT_DIR$/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java - 640 + 641 @@ -1617,22 +1671,58 @@ @@ -1641,69 +1731,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + @@ -1711,143 +1748,105 @@ - + - - - - - - - - + - + - + - + - - - - - - - - + - - - - - - - - + - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + @@ -1855,73 +1854,27 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + @@ -1929,109 +1882,194 @@ - + - + - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + - - + + + + + + + + + + - + - - + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + @@ -2040,17 +2078,94 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 1228677ca888 -r 3af5f4af2d63 src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java --- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Thu Nov 19 17:18:23 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Tue Nov 24 02:18:51 2015 +0900 @@ -41,7 +41,11 @@ // readSend does not peform unzip, do the fullrecoding rfb.readSendData(dataLen, reader, null, rect); reader.reset(); - reader.skip(16); + if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { + reader.skip(24); + } else { + reader.skip(16); + } decoder.decode(reader, renderer, rect); return; } @@ -54,9 +58,12 @@ int zrleLength = 0; if (rect.getEncodingType() == EncodingType.ZRLE || rect.getEncodingType() == EncodingType.ZRLEE - || rect.getEncodingType() == EncodingType.ZLIB) { + || rect.getEncodingType() == EncodingType.ZLIB || rect.getEncodingType() == EncodingType.CHECK_DELAY) { zrleLength = reader.readInt32(); } + if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { + return zrleLength + 28; + } return zrleLength + 20; } diff -r 1228677ca888 -r 3af5f4af2d63 src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Thu Nov 19 17:18:23 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Nov 24 02:18:51 2015 +0900 @@ -135,7 +135,7 @@ reader.mark(20+8+4); getLost(reader); //check seq consistency } else { - reader.mark(20); + reader.mark(20+8); } byte messageId = reader.readByte(); @@ -328,11 +328,14 @@ } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { int checkDelaySize = 24; - reader.reset(); - rfb.readSendData(checkDelaySize, reader, null, rect); int port = rfb.acceptPort; String address = rfb.getMyAddress(); - sendCheckDelayReply(rect.time, port, address); + int dataLen = reader.readInt32(); + sendCheckDelayReply(rect.time, port, address, dataLen); + reader.reset(); + reader.readBytes(24); + decoder = decoders.getDecoderByType(EncodingType.ZRLEE); + decoder.decode(reader, renderer, rect); // TreeVNC processing here } else if (rect.getEncodingType() == EncodingType.SOUND) { // SOUNDを受信した時の処理を } else if (rect.getEncodingType() == EncodingType.ERROR_ANNOUNCE) { @@ -374,8 +377,8 @@ } } - private void sendCheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { - context.sendMessage(new CheckDelayReply(time, port, address)); + private void sendCheckDelayReply(long time, int port, String address, int dataLen) throws UnsupportedEncodingException { + context.sendMessage(new CheckDelayReply(time, port, address, dataLen)); } public synchronized void queueUpdatePixelFormat(PixelFormat pf) { diff -r 1228677ca888 -r 3af5f4af2d63 src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Thu Nov 19 17:18:23 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Tue Nov 24 02:18:51 2015 +0900 @@ -13,25 +13,28 @@ private long time; private int port; private int addressLength; + private int dataLen; private byte[] byteaddress; - public CheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { + public CheckDelayReply(long time, int port, String address, int dataLen) throws UnsupportedEncodingException { this.time = time; this.port = port; this.addressLength = address.length(); + this.dataLen = dataLen; this.byteaddress = address.getBytes("UTF-8"); } @Override public void send(Writer writer) throws TransportException { - ByteBuffer out = ByteBuffer.allocate(18 + addressLength); + ByteBuffer out = ByteBuffer.allocate(22 + addressLength); out.order(ByteOrder.BIG_ENDIAN); out.put(CHECK_DELAY_REPLY); out.put((byte)0); // padding out.putLong(time); out.putInt(port); out.putInt(addressLength); + out.putInt(dataLen); out.put(byteaddress); writer.write(out.array(), 0, out.position()); writer.flush(); diff -r 1228677ca888 -r 3af5f4af2d63 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Thu Nov 19 17:18:23 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Nov 24 02:18:51 2015 +0900 @@ -236,13 +236,14 @@ Long time = buf.getLong(); int port = buf.getInt(); int addressLength = buf.getInt(); + int dataLen = buf.getInt(); byte[] byteAddress = new byte[addressLength]; buf.get(byteAddress); String address = new String(byteAddress, "UTF-8"); int nodeNum = getNodeNum(port, address); Long delay = System.currentTimeMillis() - time; - double halfDelay = (double) delay / 2; - System.out.println(System.currentTimeMillis() + " : receive checkDelay : nodeNum" + nodeNum + ", port : " + port + ", address : " + address + ", delay : " + halfDelay); + double halfDelay = (double) delay; + System.out.println(System.currentTimeMillis() + " : receive checkDelay : nodeNum" + nodeNum + ", port : " + port + ", address : " + address + ", delay : " + halfDelay + ", size : " + dataLen); } // case of client node. } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { @@ -670,15 +671,16 @@ public void readSendData(int dataLen, Reader reader, byte[] bytes, FramebufferUpdateRectangle rect) throws TransportException, UnsupportedEncodingException { LinkedList bufs = new LinkedList(); - ByteBuffer header = multicastqueue.allocate(16); + int headerLen = rect.getEncodingType() == EncodingType.CHECK_DELAY ? 24 : 16; + ByteBuffer header = multicastqueue.allocate(headerLen); ByteBuffer serial = multicastqueue.allocate(4+8); if (!isTreeManager() && addSerialNum) { reader.readBytes(serial.array(),0,4+8); serial.limit(4+8); } reader.mark(dataLen); - reader.readBytes(header.array(), 0, 16); - header.limit(16); + reader.readBytes(header.array(), 0, headerLen); + header.limit(headerLen); if (header.get(0) == FramebufferUpdate) { int encoding = header.getInt(12); @@ -710,6 +712,7 @@ blen.putInt(len2); blen.flip(); bufs.addFirst(blen); + LinkedList bufs2 = (LinkedList)bufs.clone(); bufs.addFirst(header); if (addSerialNum) { addSerialNumber(bufs); @@ -721,6 +724,7 @@ } else { multicastqueue.put(bufs); } + sendCheckDelay(bufs2, header); } catch (IOException e) { throw new TransportException(e); } catch (DataFormatException e) { @@ -734,10 +738,10 @@ if (addSerialNum) { this.addSerialNumber(bufs); } - if (dataLen > 16) { - ByteBuffer b = multicastqueue.allocate(dataLen - 16); - reader.readBytes(b.array(), 0, dataLen - 16); - b.limit(dataLen - 16); + if (dataLen > headerLen) { + ByteBuffer b = multicastqueue.allocate(dataLen - headerLen); + reader.readBytes(b.array(), 0, dataLen - headerLen); + b.limit(dataLen - headerLen); bufs.add(b); } multicastqueue.put(bufs); @@ -752,6 +756,16 @@ // here. } + public void sendCheckDelay(LinkedList checkDelay, ByteBuffer header) { + int x = (int)header.getShort(4); + int y = (int)header.getShort(6); + int width = (int)header.getShort(8); + int height = (int)header.getShort(10); + long time = System.currentTimeMillis(); + checkDelay.addFirst(new CheckDelay(x, y, width, height, time, EncodingType.CHECK_DELAY).getMessage()); + multicastqueue.put(checkDelay); + } + public void setId(short id) { this.id = id; }