Mercurial > hg > RemoteEditor > REPSessionManager
changeset 46:4fdeeb2d5645
UTF-8 Pack Method PackUConv() add
author | fuchita |
---|---|
date | Tue, 13 Nov 2007 17:35:43 +0900 |
parents | 10f1adf6d74d |
children | f4eb7fd098c4 |
files | rep/REPPacketReceive.java |
diffstat | 1 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/REPPacketReceive.java Sun Nov 11 00:26:35 2007 +0900 +++ b/rep/REPPacketReceive.java Tue Nov 13 17:35:43 2007 +0900 @@ -57,16 +57,27 @@ int eid = header.getInt(); int seqid = header.getInt(); int lineno = header.getInt(); - int textsiz = header.getInt()/5; + int textsiz = header.getInt(); + //int tmptextsiz = header.getInt(); + //int textsiz = (tmptextsiz /5) + (tmptextsiz % 5); - ByteBuffer textBuffer = ByteBuffer.allocateDirect(textsiz*5); - + ByteBuffer textBuffer = ByteBuffer.allocateDirect(textsiz); + try { len = socketchannel.read(textBuffer); + if(len == -1){ + if(key != null){ + key.cancel(); + } + socketchannel.close(); + return null; + }else if(len == 0){ + return null; + } } catch (IOException e1) { e1.printStackTrace(); } // limit = read length - if (len != textsiz * 5) { + if (len != textsiz) { // this can't happen System.out.println("‚ ‚Æ"); } @@ -81,6 +92,7 @@ } catch (CharacterCodingException e) { e.printStackTrace(); } + cb.rewind(); String string = cb.toString(); @@ -89,6 +101,7 @@ //System.out.println(cb.toString()); REPCommand repcommand = new REPCommand(cmd, sid, eid, seqid, lineno, textsiz, string); + System.out.println("UnPack Packet: => cmd:"+cmd+" sid:"+sid+" eid:"+eid+"seqid:"+seqid+" lineno:"+lineno+" textsiz:" +textsiz+" text: "+string); System.out.println("received command: " + repcommand.toString()); return repcommand;