Mercurial > hg > Applications > TreeVNC
changeset 234:8479ad028ec7
fix checkdelay send and get.
author | oc |
---|---|
date | Sat, 11 Oct 2014 02:47:17 +0900 |
parents | 26b7c0a6d91b |
children | 15e66adbb8bb |
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, 39 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Fri Oct 10 23:43:06 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/FramebufferUpdateRectangle.java Sat Oct 11 02:47:17 2014 +0900 @@ -68,12 +68,6 @@ encodingType = EncodingType.byId(encoding); if (encoding == 17) { time = reader.readInt64(); - port = reader.readInt32(); - int localhostlength = reader.readInt32(); - byte[] bytelocalhost = new byte[localhostlength]; - bytelocalhost = reader.readBytes(bytelocalhost, 0, localhostlength); - localhost = new String(bytelocalhost, "UTF-8"); -// System.out.println("time = " + time); } }
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Oct 10 23:43:06 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Sat Oct 11 02:47:17 2014 +0900 @@ -129,14 +129,6 @@ logger.fine("Server message: CutText (3)"); serverCutText(); break; - case CHECK_DELAY: - ZRLEESender sender = new ZRLEESender(rfb); - sender.readCheckDelay(reader); - /* - reader.readBytes(15); - System.out.println("delay_time="+(System.currentTimeMillis() - reader.readInt64())); - */ - break; default: logger.severe("Unsupported server message. Id = " + messageId); } @@ -263,13 +255,13 @@ context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); // repaintController.repaintCursor(); } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { - readCheckDelay(reader); int length = reader.readInt32(); reader.reset(); + rfb.readSendData(length + 24, reader, null); - rfb.readSendData(length + 52, reader, null); - // System.out.println("rect.time=" + rect.time); - sendCheckDelayReply(rect.time); + int port = rfb.acceptPort; + String address = rfb.getMyAddress(); + sendCheckDelayReply(rect.time, port, address); } else throw new CommonException("Unprocessed encoding: " + rect.toString()); } @@ -290,8 +282,8 @@ } } - private void sendCheckDelayReply(long time) { - context.sendMessage(new CheckDelayReply(time)); + private void sendCheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { + context.sendMessage(new CheckDelayReply(time, port, address)); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Fri Oct 10 23:43:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java Sat Oct 11 02:47:17 2014 +0900 @@ -1,5 +1,6 @@ package jp.ac.u_ryukyu.treevnc; +import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -10,18 +11,29 @@ public class CheckDelayReply implements ClientToServerMessage { private long time; + private int port; + private String address; + private int addressLength; + private byte[] byteaddress; - public CheckDelayReply(long time) { + 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"); } @Override public void send(Writer writer) throws TransportException { - ByteBuffer out = ByteBuffer.allocate(10); + ByteBuffer out = ByteBuffer.allocate(18 + addressLength); out.order(ByteOrder.BIG_ENDIAN); out.put(CHECK_DELAY_REPLY); out.put((byte)0); out.putLong(time); + out.putInt(port); + out.putInt(addressLength); + out.put(byteaddress); writer.write(out.array(), 0, out.position()); writer.flush(); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Oct 10 23:43:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Sat Oct 11 02:47:17 2014 +0900 @@ -172,7 +172,14 @@ ByteBuffer buf = ByteBuffer.wrap(b); buf.order(ByteOrder.BIG_ENDIAN); // getNodeNum(port, hostname, localhostname); - Long time = buf.getLong(2); + buf.getShort(); + Long time = buf.getLong(); + int port = buf.getInt(); + int addressLength = buf.getInt(); + byte[] byteAddress = new byte[addressLength]; + buf.get(byteAddress); + String address = new String(byteAddress, "UTF-8"); + Long delay = System.currentTimeMillis() - time; System.out.println("delay = " + delay); } @@ -565,17 +572,15 @@ if (header.get(0) == FramebufferUpdate) { int encoding = header.getInt(12); - - if (i%20 == 0) { - LinkedList<ByteBuffer> checkdelay = new LinkedList<ByteBuffer>(); - long time = System.currentTimeMillis(); - int port = 1234; - String localhost = "133.13.11.9"; - String mylocalhost = "localhost"; - checkdelay.add(new UpdateRectangleMessage(0, 0, 0, 0, time, port, localhost, EncodingType.CHECK_DELAY).getMessage()); - this.addSerialNumber(checkdelay); - multicastqueue.put(checkdelay); - } i++; + if(isTreeManager()) { + 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()); + this.addSerialNumber(checkdelay); + multicastqueue.put(checkdelay); + } i++; + } if (encoding == EncodingType.ZRLE.getId()
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Fri Oct 10 23:43:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java Sat Oct 11 02:47:17 2014 +0900 @@ -11,10 +11,9 @@ private ByteBuffer msg; public UpdateRectangleMessage(int i, int j, int width, int height, long time, - int port, String localhost, EncodingType desktopSize) throws UnsupportedEncodingException { - byte[] bytelocalhost = localhost.getBytes("UTF-8"); + EncodingType desktopSize) throws UnsupportedEncodingException { - msg = ByteBuffer.allocate(52).order(ByteOrder.BIG_ENDIAN); + 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 @@ -24,9 +23,6 @@ msg.putShort((short) height); msg.putInt(desktopSize.getId()); msg.putLong(time); - msg.putInt(port); - msg.putInt(localhost.length()); - msg.put(bytelocalhost); msg.flip();