Mercurial > hg > Applications > TreeVNC
changeset 237:0815ed7f54a7
clean code.
author | oc |
---|---|
date | Sat, 11 Oct 2014 14:13:29 +0900 |
parents | 49762c621bd6 |
children | e21ef8f60f7a |
files | 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/CheckDelayReply.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, 10 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Sat Oct 11 14:13:16 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Sat Oct 11 14:13:29 2014 +0900 @@ -64,9 +64,9 @@ width = reader.readUInt16(); height = reader.readUInt16(); int encoding = reader.readInt32(); + encodingType = EncodingType.byId(encoding); - encodingType = EncodingType.byId(encoding); - if (encoding == 17) { + if (encoding == EncodingType.CHECK_DELAY.getId()) { time = reader.readInt64(); } }
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Sat Oct 11 14:13:16 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Sat Oct 11 14:13:29 2014 +0900 @@ -56,7 +56,6 @@ 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 Logger logger = Logger.getLogger("com.glavsoft.rfb.protocol.ReceiverTask"); @@ -256,8 +255,9 @@ // repaintController.repaintCursor(); } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { int length = reader.readInt32(); + int checkDelaySize = length + 24; reader.reset(); - rfb.readSendData(length + 24, reader, null); + rfb.readSendData(checkDelaySize, reader, null); int port = rfb.acceptPort; String address = rfb.getMyAddress(); @@ -287,10 +287,6 @@ } - 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/CheckDelayReply.java Sat Oct 11 14:13:16 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Sat Oct 11 14:13:29 2014 +0900 @@ -12,18 +12,20 @@ private long time; private int port; - private String address; private int addressLength; private byte[] byteaddress; public CheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { this.time = time; this.port = port; - this.address = address; this.addressLength = address.length(); this.byteaddress = address.getBytes("UTF-8"); } + public CheckDelayReply() { + // TODO Auto-generated constructor stub + } + @Override public void send(Writer writer) throws TransportException { ByteBuffer out = ByteBuffer.allocate(18 + addressLength);
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Oct 11 14:13:16 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Oct 11 14:13:29 2014 +0900 @@ -181,7 +181,7 @@ String address = new String(byteAddress, "UTF-8"); int nodeNum = getNodeNum(port, address); Long delay = System.currentTimeMillis() - time; - System.out.println("delay = " + delay); + System.out.println("nodeNum" + nodeNum + ", delay = " + delay); } } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { ClientToServerMessage sc = new ClientToServerMessage() { @@ -200,12 +200,8 @@ writer.write(b,0,c); } }; - ByteBuffer buf = ByteBuffer.wrap(b); - buf.order(ByteOrder.BIG_ENDIAN); - Long time = buf.getLong(2); // 確認用 context.sendMessage(checkDelayReply); } - // System.out.println("client read "+c); } catch (Exception e) { try { writerRunning.set(2); @@ -576,13 +572,12 @@ if (i%20 == 0) { LinkedList<ByteBuffer> checkdelay = new LinkedList<ByteBuffer>(); long time = System.currentTimeMillis(); - checkdelay.add(new UpdateRectangleMessage(0, 0, 0, 0, time, EncodingType.CHECK_DELAY).getMessage()); + checkdelay.add(new CheckDelay(0, 0, 0, 0, time, EncodingType.CHECK_DELAY).getMessage()); this.addSerialNumber(checkdelay); multicastqueue.put(checkdelay); } i++; } - if (encoding == EncodingType.ZRLE.getId() || encoding == EncodingType.ZLIB.getId()) { // recompress into ZREE @@ -595,7 +590,6 @@ inputData.limit(dataLen - 20); LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>(); inputs.add(inputData); - header.putInt(12, EncodingType.ZRLEE.getId()); // means // recompress // every time @@ -623,7 +617,6 @@ return; } - // ZRLEE is already compressed bufs.add(header); if (dataLen > 16) { @@ -635,10 +628,6 @@ this.addSerialNumber(bufs); multicastqueue.put(bufs); - - - - return; } // It may be compressed. We can inflate here to avoid repeating clients @@ -764,8 +753,6 @@ for (Iterator<TreeVNCNode> i = nodeList.iterator(); i.hasNext();) { TreeVNCNode tvn = (TreeVNCNode)i.next(); - System.out.println("checkdelay : port = " + port + ", hostname = " + address); - System.out.println("nodeList : port = " + tvn.port + ", hostname = " + tvn.hostname + ", nodeNumber" + tvn.treeNum); if (port == tvn.port && address.equals(tvn.hostname)) { nodeNum = tvn.treeNum; return nodeNum;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Sat Oct 11 14:13:16 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Sat Oct 11 14:13:29 2014 +0900 @@ -1,6 +1,5 @@ package jp.ac.u_ryukyu.treevnc; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -10,24 +9,6 @@ private ByteBuffer msg; - public UpdateRectangleMessage(int i, int j, int width, int height, long time, - EncodingType desktopSize) throws UnsupportedEncodingException { - - msg = ByteBuffer.allocate(24).order(ByteOrder.BIG_ENDIAN); - msg.put((byte) 0); // FrameBufferUpdate - msg.put((byte) 0); // padding - msg.putShort((short) 1); // number of rectangle - msg.putShort((short) i); - msg.putShort((short) j); - msg.putShort((short) width); - msg.putShort((short) height); - msg.putInt(desktopSize.getId()); - msg.putLong(time); - - msg.flip(); - - } - public UpdateRectangleMessage(int width, int height, EncodingType desktopSize, byte[] initData, short id) { msg = ByteBuffer.allocate(16+4+initData.length).order(ByteOrder.BIG_ENDIAN);