Mercurial > hg > RemoteEditor > REPSessionManager
changeset 51:e9fba549803e
UTF-8 Pack Method packUConv()/unpackUConv() add
author | fuchita |
---|---|
date | Tue, 13 Nov 2007 19:57:21 +0900 |
parents | 6f23795f61c9 |
children | afddc6fe8d8d |
files | rep/REPPacketReceive.java rep/REPPacketSend.java |
diffstat | 2 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/REPPacketReceive.java Tue Nov 13 19:12:00 2007 +0900 +++ b/rep/REPPacketReceive.java Tue Nov 13 19:57:21 2007 +0900 @@ -15,6 +15,7 @@ SocketChannel socketchannel; private final int HEADER_SIZE = 24; + private final int CHAR_ORDER = 3; //private String host; //private int port; SelectionKey key; @@ -154,8 +155,11 @@ String string = cb.toString(); + textsiz = string.length(); + //System.out.println("CharBuffer size: " +cb.length()); + //System.out.println("textsize: " +textsiz); - //System.out.println("CharBuffer size: " +cb.length()); + //System.out.println(cb.toString()); REPCommand repcommand = new REPCommand(cmd, sid, eid, seqid, lineno, textsiz, string);
--- a/rep/REPPacketSend.java Tue Nov 13 19:12:00 2007 +0900 +++ b/rep/REPPacketSend.java Tue Nov 13 19:57:21 2007 +0900 @@ -39,7 +39,7 @@ if(command.string == null){ command.setString("test"); } - ByteBuffer buffer = ByteBuffer.allocateDirect(24+(command.string).length()*CHAR_ORDER); + ByteBuffer buffer = ByteBuffer.allocateDirect(24+(command.string.length()*CHAR_ORDER)); buffer.clear(); // position = 0 buffer.putInt(command.cmd); buffer.putInt(command.sid); buffer.putInt(command.eid); buffer.putInt(command.seq); buffer.putInt(command.lineno); @@ -57,10 +57,13 @@ e.printStackTrace(); } + int length = (buffer.position() -pos) -4; System.out.println("UTF-8: Set REPComand textlen(Byte) : " + (buffer.position() - pos-4)); //Encoded string length set - buffer.putInt(pos, (buffer.position()-pos-4)); - buffer.flip(); + buffer.putInt(pos, length); + + buffer.limit(24+length); + buffer.rewind(); return buffer; }