# HG changeset patch # User e165729 # Date 1580103658 -32400 # Node ID 9c0cbe1191553be493c0d8b31c1008e1de65ab9a # Parent e6815421128664c0ee3463f6fb431083cec4b9b5 fix make rectangle packet in client diff -r e68154211286 -r 9c0cbe119155 src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java --- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Sat Jan 04 17:34:01 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java Mon Jan 27 14:40:58 2020 +0900 @@ -108,9 +108,8 @@ CheckDelay.checkDelay(c1, rect.x, rect.y, rect.width, rect.height, System.currentTimeMillis(), EncodingType.CHECK_DELAY); c1.put((byte) 0); c1.put((byte) 0); - c1.put((byte) 0); c1.putShort((short) 0); - c1.position(c1.position() + 16); + c1.position(c1.position() + 12); c1.putInt(0); // should be data length prevC1Offset = c1.position(); prevC1LineOffset = prevC1Offset; @@ -190,27 +189,26 @@ if (!deflater.needsInput()) { deflater.finish(); if (offset != prevLineOffset) { - // fix phase1 rectangle header - c1.putShort(prevC1Offset + 0, (short) c1rect.x); - c1.putShort(prevC1Offset + 2, (short) c1rect.y); - c1.putShort(prevC1Offset + 4, (short) c1rect.width); - c1.putShort(prevC1Offset + 6, (short) c1rect.height); - c1.putInt(prevC1Offset + 8, EncodingType.ZRLEE.getId()); - c1.putInt(prevC1Offset + 12, c1.position() - prevC1LineOffset - 12); // data length - c1.putShort(2, (short) (c1.getShort(2) + 1)); // increment rectangle count + //c1.putShort(prevC1Offset - 16, (short) c1rect.x); + //c1.putShort(prevC1Offset - 14, (short) c1rect.y); + //c1.putShort(prevC1Offset - 12, (short) c1rect.width); + //c1.putShort(prevC1Offset - 10, (short) c1rect.height); + //c1.putInt(prevC1Offset - 8, EncodingType.ZRLEE.getId()); + //c1.putInt(prevC1Offset - 4, c1.position() - prevC1LineOffset - 12); // data length + //c1.putShort(2, (short) (c1.getShort(2) + 1)); // increment rectangle count - if (c1rect.x == rect.x) { // phase0 needs no phase1 - // make header space for phase2 - c1.limit(c1.limit() + headerLength); - int pos = c1.position() - 1; - // to make rectangle header shift last bytes - for (int i = 0; i < pos - prevC1LineOffset; i++) { - c1.array()[pos + headerLength - i] = c1.array()[pos - i]; - } - prevC1Offset = prevC1LineOffset; - } + //if (c1rect.x == rect.x) { // phase0 needs no phase1 + // // make header space for phase2 + // c1.limit(c1.limit() + headerLength); + // int pos = c1.position() - 1; + // // to make rectangle header shift last bytes + // for (int i = 0; i < pos - prevC1LineOffset; i++) { + // c1.array()[pos + headerLength - i] = c1.array()[pos - i]; + // } + // prevC1Offset = prevC1LineOffset; + //} } flushRectangle(rect); flushMuticast(rfb); @@ -232,12 +230,12 @@ * send muticast pacate if nessesally */ private void flushRectangle(FramebufferUpdateRectangle rect) { - c1.putShort(prevC1Offset + 0, (short) c1rect.x); - c1.putShort(prevC1Offset + 2, (short) c1rect.y); - c1.putShort(prevC1Offset + 4, (short) c1rect.width); - c1.putShort(prevC1Offset + 6, (short) c1rect.height); - c1.putInt(prevC1Offset + 8, EncodingType.ZRLEE.getId()); - c1.putInt(prevC1Offset + 12, c1.position() - prevC1Offset - 12); // data length + c1.putShort(prevC1Offset - 16, (short) c1rect.x); + c1.putShort(prevC1Offset - 14, (short) c1rect.y); + c1.putShort(prevC1Offset - 12, (short) c1rect.width); + c1.putShort(prevC1Offset - 10, (short) c1rect.height); + c1.putInt(prevC1Offset - 8, EncodingType.ZRLEE.getId()); + c1.putInt(prevC1Offset - 4, c1.position() - prevC1Offset - 12); // data length c1.putShort(2, (short) (c1.getShort(2) + 1)); // increment rectangle count prevC1Offset = c1.position(); @@ -303,7 +301,7 @@ int maxY = rect.y + rect.height; TileLoop tileloop = new TileLoop(zippedLength); - //System.out.println("decode1: "+rect); + //System.out.println("decode1: "+rect.toString()); if (null == palette) { palette = new int[128]; } diff -r e68154211286 -r 9c0cbe119155 src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java --- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java Sat Jan 04 17:34:01 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java Mon Jan 27 14:40:58 2020 +0900 @@ -59,7 +59,7 @@ } decoder.setInput(bytes, 0, zippedLength); try { - messageDump(bytes, "infrate: "); + //messageDump(bytes, "inflate: "); decoder.inflate(bytes, zippedLength, length); } catch (DataFormatException e) { throw new TransportException("cannot inflate Zlib data", e); diff -r e68154211286 -r 9c0cbe119155 src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Sat Jan 04 17:34:01 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Jan 27 14:40:58 2020 +0900 @@ -203,7 +203,7 @@ } else { reader.mark(20+4); } - //rfb.messageDump(reader, "get receive massage: "); + rfb.messageDump(reader, "get receive massage: "); return reader.readByte(); } diff -r e68154211286 -r 9c0cbe119155 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Jan 04 17:34:01 2020 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Mon Jan 27 14:40:58 2020 +0900 @@ -350,7 +350,7 @@ while (inputIndex < bufs.size()) { ByteBuffer b = bufs.get(inputIndex++); os.write(b.array(), b.position(), b.limit()); - //messageDump(new Reader(new ByteArrayInputStream(b.array())), "write to client: "); + messageDump(new Reader(new ByteArrayInputStream(b.array())), "write to client: "); } os.flush(); multicastqueue.heapAvailable(); @@ -958,7 +958,7 @@ public void messageDump(Reader reader, String msg) { System.out.print(msg); try { - reader.mark(30); + reader.mark(24); for (int i = 0; i < 24; i++) { // 20 + 4 System.out.print(String.format("%02x ", reader.readByte())); }