Mercurial > hg > Applications > TreeVNC
changeset 164:86289e56263c
Send initData in server change
author | oc |
---|---|
date | Wed, 18 Jun 2014 21:16:28 +0900 |
parents | c850c2fce039 |
children | 93c6ba4d3bc4 |
files | src/main/java/com/glavsoft/rfb/encoding/EncodingType.java src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java |
diffstat | 5 files changed, 40 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Tue Jun 17 09:56:47 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Wed Jun 18 21:16:28 2014 +0900 @@ -65,6 +65,11 @@ ZRLEE(15, "ZRLEE"), /** + * Transmit initial data of new display + */ + INIT_DATA(0xFFFFFF10, "InitData"), + + /** * Rich Cursor pseudo encoding which allows to transfer cursor shape * with transparency */
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Jun 17 09:56:47 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Wed Jun 18 21:16:28 2014 +0900 @@ -43,6 +43,7 @@ import java.io.PrintWriter; import java.io.StringWriter; +import java.nio.ByteBuffer; import java.util.logging.Logger; import jp.ac.u_ryukyu.treevnc.MyRfbProto; @@ -237,10 +238,16 @@ } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { renderer.decodeCursorPosition(rect); repaintController.repaintCursor(); - } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE) { + } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE || rect.getEncodingType() == EncodingType.INIT_DATA ) { fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, true); rfb.setCuiVersion(false); + if (rect.getEncodingType() == EncodingType.INIT_DATA) { + int length = reader.readInt32(); + byte[] initData = new byte[length]; + reader.read(initData); + rfb.getContext().setInitData(initData); + } synchronized (renderer.getLock()) { if(!(rfb.getCuiVersion())) renderer = repaintController.createRenderer(reader, rect.width, rect.height,context.getPixelFormat());
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Tue Jun 17 09:56:47 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Wed Jun 18 21:16:28 2014 +0900 @@ -58,6 +58,10 @@ abstract public boolean isRoot() ; + public ProtocolContext getContext() { + return context; + } + /** * handle new client accept * it also handle TreeVNC Command @@ -362,7 +366,7 @@ LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>(); int width = context.getFbWidth(); int height = context.getFbHeight(); - desktopSize.add(new UpdateRectangleMessage(0,0, width, height, EncodingType.DESKTOP_SIZE).getMessage()); + desktopSize.add(new UpdateRectangleMessage(width, height, EncodingType.INIT_DATA, context.getInitData()).getMessage()); addSerialNumber(desktopSize); multicastqueue.put(desktopSize); } @@ -571,5 +575,5 @@ } - + }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Tue Jun 17 09:56:47 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommandChannelListener.java Wed Jun 18 21:16:28 2014 +0900 @@ -211,7 +211,7 @@ in.readBytes(b); } - byte initData[] = {7, -128, 4, 56, 32, 24, 0, 1, 0, -1, 0, -1, 0, -1, 16, 8, 0, 0, 0, 0, 0, 0, 0, 7, 102, 105, 114, 101, 102, 108, 121}; + byte initData[] = {7, -128, 4, 56, 32, 24, 0, 1, 0, -1, 0, -1, 0, -1, 16, 8, 0, 0, 0, 0, 0, 0, 0, 7, 103, 105, 114, 101, 102, 108, 121}; void sendInitData(Writer os) throws TransportException { // In case of "-d" we have no context ProtocolContext context = rfb.context;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Tue Jun 17 09:56:47 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Wed Jun 18 21:16:28 2014 +0900 @@ -7,11 +7,11 @@ public class UpdateRectangleMessage { - private ByteBuffer msg = ByteBuffer.allocate(16).order(ByteOrder.BIG_ENDIAN); + private ByteBuffer msg; public UpdateRectangleMessage(int i, int j, int width, int height, EncodingType desktopSize) { - + 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 @@ -25,6 +25,24 @@ } + public UpdateRectangleMessage(int width, int height, + EncodingType desktopSize, byte[] initData) { + msg = ByteBuffer.allocate(16+4+initData.length).order(ByteOrder.BIG_ENDIAN); + msg.put((byte) 0); // FrameBufferUpdate + msg.put((byte) 0); // padding + msg.putShort((short) 1); // number of rectangle + msg.putShort((short) 0); + msg.putShort((short) 0); + msg.putShort((short) width); + msg.putShort((short) height); + msg.putInt(desktopSize.getId()); + msg.putInt(initData.length); + msg.put(initData); + + msg.flip(); + + } + public ByteBuffer getMessage(){ return msg; }