Mercurial > hg > Members > riono > TreeVNC_ja_comment
comparison src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java @ 414:3af5f4af2d63
Send data size for checkDelay
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Nov 2015 02:18:51 +0900 |
parents | 9c5874d0f37e |
children |
comparison
equal
deleted
inserted
replaced
413:1228677ca888 | 414:3af5f4af2d63 |
---|---|
11 public class CheckDelayReply implements ClientToServerMessage { | 11 public class CheckDelayReply implements ClientToServerMessage { |
12 | 12 |
13 private long time; | 13 private long time; |
14 private int port; | 14 private int port; |
15 private int addressLength; | 15 private int addressLength; |
16 private int dataLen; | |
16 private byte[] byteaddress; | 17 private byte[] byteaddress; |
17 | 18 |
18 public CheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { | 19 public CheckDelayReply(long time, int port, String address, int dataLen) throws UnsupportedEncodingException { |
19 this.time = time; | 20 this.time = time; |
20 this.port = port; | 21 this.port = port; |
21 this.addressLength = address.length(); | 22 this.addressLength = address.length(); |
23 this.dataLen = dataLen; | |
22 this.byteaddress = address.getBytes("UTF-8"); | 24 this.byteaddress = address.getBytes("UTF-8"); |
23 } | 25 } |
24 | 26 |
25 | 27 |
26 @Override | 28 @Override |
27 public void send(Writer writer) throws TransportException { | 29 public void send(Writer writer) throws TransportException { |
28 ByteBuffer out = ByteBuffer.allocate(18 + addressLength); | 30 ByteBuffer out = ByteBuffer.allocate(22 + addressLength); |
29 out.order(ByteOrder.BIG_ENDIAN); | 31 out.order(ByteOrder.BIG_ENDIAN); |
30 out.put(CHECK_DELAY_REPLY); | 32 out.put(CHECK_DELAY_REPLY); |
31 out.put((byte)0); // padding | 33 out.put((byte)0); // padding |
32 out.putLong(time); | 34 out.putLong(time); |
33 out.putInt(port); | 35 out.putInt(port); |
34 out.putInt(addressLength); | 36 out.putInt(addressLength); |
37 out.putInt(dataLen); | |
35 out.put(byteaddress); | 38 out.put(byteaddress); |
36 writer.write(out.array(), 0, out.position()); | 39 writer.write(out.array(), 0, out.position()); |
37 writer.flush(); | 40 writer.flush(); |
38 } | 41 } |
39 | 42 |