Mercurial > hg > Applications > TreeVNC
changeset 226:b7247e31b5ba
send checkdelay sample.
author | oc |
---|---|
date | Sun, 05 Oct 2014 16:09:23 +0900 |
parents | 5e3594021e79 |
children | 2cb2279ca95c |
files | src/main/java/com/glavsoft/rfb/encoding/EncodingType.java src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java |
diffstat | 5 files changed, 41 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Tue Jul 15 07:18:13 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Sun Oct 05 16:09:23 2014 +0900 @@ -63,6 +63,11 @@ * ZRLEE Encoding is extends ZRLE. ZRLEE have flush(). */ ZRLEE(15, "ZRLEE"), + + /** + * TreeVNC check delay protocol number. + */ + CHECK_DELAY(17, "CHECK_DELAY"), /** * Transmit initial data of new display
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Tue Jul 15 07:18:13 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Sun Oct 05 16:09:23 2014 +0900 @@ -59,7 +59,11 @@ width = reader.readUInt16(); height = reader.readUInt16(); int encoding = reader.readInt32(); + encodingType = EncodingType.byId(encoding); + if (encoding == 17) { + System.out.println("checkdelay~~~~~~"); + } } public EncodingType getEncodingType() {
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Jul 15 07:18:13 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Sun Oct 05 16:09:23 2014 +0900 @@ -44,17 +44,20 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.util.LinkedList; import java.util.logging.Logger; import jp.ac.u_ryukyu.treevnc.TreeRFBProto; import jp.ac.u_ryukyu.treevnc.TreeVncProtocol; +import jp.ac.u_ryukyu.treevnc.UpdateRectangleMessage; public class ReceiverTask implements Runnable { private static final byte FRAMEBUFFER_UPDATE = 0; private static final byte SET_COLOR_MAP_ENTRIES = 1; private static final byte BELL = 2; private static final byte SERVER_CUT_TEXT = 3; - private static final byte Check_Delay = 11; + private static final byte CHECK_DELAY = 11; private static Logger logger = Logger.getLogger("com.glavsoft.rfb.protocol.ReceiverTask"); @@ -127,7 +130,7 @@ logger.fine("Server message: CutText (3)"); serverCutText(); break; - case Check_Delay: + case CHECK_DELAY: ZRLEESender sender = new ZRLEESender(rfb); sender.readCheckDelay(reader); /* @@ -215,6 +218,11 @@ public void framebufferUpdateMessage() throws CommonException, UnsupportedEncodingException { reader.readByte(); // padding int numberOfRectangles = reader.readUInt16(); + + if (numberOfRectangles == 1234) { + System.out.println("1~~~~~~~~"); + } + while (numberOfRectangles-- > 0) { FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); rect.fill(reader); @@ -259,9 +267,13 @@ } context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); // repaintController.repaintCursor(); + } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY ) { + readCheckDelay(reader); } else throw new CommonException("Unprocessed encoding: " + rect.toString()); } + + if (!rfb.isTreeManager()) return; synchronized (this) { if (needSendPixelFormat) { @@ -277,6 +289,10 @@ } } + private void readCheckDelay(Reader reader) { + System.out.println("read check delay."); + } + public synchronized void queueUpdatePixelFormat(PixelFormat pf) { pixelFormat = pf; needSendPixelFormat = true;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Tue Jul 15 07:18:13 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sun Oct 05 16:09:23 2014 +0900 @@ -207,19 +207,11 @@ for (;;) { LinkedList<ByteBuffer> bufs = c.poll(); + int inputIndex = 0; ByteBuffer header = bufs.get(inputIndex); if (header == null) continue; - else if (header.get(0) == CheckDelay) { - writeToClient(os, bufs, inputIndex); - continue; - } else if (header.get(0) == FramebufferUpdate) { - //System.out.println("client "+ myId); - } - /* - * if(i%20==0){ sendDataCheckDelay(); } i++; - */ writeToClient(os, bufs, inputIndex); writerRunning.set(1); // yes my client is awaking. } @@ -549,6 +541,13 @@ header.limit(16); if (header.get(0) == FramebufferUpdate) { int encoding = header.getInt(12); + + LinkedList<ByteBuffer> checkdelay = new LinkedList<ByteBuffer>(); + checkdelay.add(new UpdateRectangleMessage(0, 0, 0, 0, EncodingType.CHECK_DELAY).getMessage()); + this.addSerialNumber(checkdelay); + multicastqueue.put(checkdelay); + + if (encoding == EncodingType.ZRLE.getId() || encoding == EncodingType.ZLIB.getId()) { // recompress into ZREE @@ -598,6 +597,11 @@ } this.addSerialNumber(bufs); multicastqueue.put(bufs); + + + + + return; } // It may be compressed. We can inflate here to avoid repeating clients
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Tue Jul 15 07:18:13 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Sun Oct 05 16:09:23 2014 +0900 @@ -14,7 +14,7 @@ msg = ByteBuffer.allocate(16).order(ByteOrder.BIG_ENDIAN); msg.put((byte) 0); // FrameBufferUpdate msg.put((byte) 0); // padding - msg.putShort((short) 1); // number of rectangle + msg.putShort((short) 1234); // number of rectangle msg.putShort((short) i); msg.putShort((short) j); msg.putShort((short) width);