Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/REPPacketSend.java @ 147:4ff68518e9ca
*** empty log message ***
author | kent |
---|---|
date | Wed, 27 Aug 2008 23:38:21 +0900 |
parents | 70fc1e70652c |
children |
line wrap: on
line diff
--- a/rep/REPPacketSend.java Wed Aug 27 23:14:39 2008 +0900 +++ b/rep/REPPacketSend.java Wed Aug 27 23:38:21 2008 +0900 @@ -3,14 +3,14 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; -import java.nio.channels.SocketChannel; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; +import rep.channel.REPPack; import rep.channel.REPSocketChannel; -public class REPPacketSend { +public class REPPacketSend implements REPPack<REPCommand> { REPSocketChannel<REPCommand> socketchannel; // JIS/S-JIS = 2, UTF-8 = 3, UTF-?? = 5 final int CHAR_ORDER = 5; @@ -19,23 +19,9 @@ socketchannel = channel; } - private ByteBuffer pack(REPCommand command){ - System.out.println("send command: " + command.toString()); - if(command.string == null){ - command.setString("test"); - } - ByteBuffer buffer = ByteBuffer.allocateDirect(24+(command.string).length()*2); - buffer.clear(); // position = 0 - buffer.putInt(command.cmd); buffer.putInt(command.sid); buffer.putInt(command.eid); - buffer.putInt(command.seq); buffer.putInt(command.lineno); - buffer.putInt(command.string.length()*2); - for(int i=0;i<command.string.length();i++) { - buffer.putChar(command.string.charAt(i)); - } - buffer.flip(); // limit = current position, position = 0 - return buffer; - } - + /* (non-Javadoc) + * @see rep.REPPack#packUConv(rep.REPCommand) + */ public ByteBuffer packUConv(REPCommand command){ System.out.println("send command byUTF8: " + command.toString()); if(command.string == null){ @@ -73,6 +59,9 @@ return buffer; } + /* (non-Javadoc) + * @see rep.REPPack#send(rep.REPCommand) + */ public void send(REPCommand command){ try { //socketchannel.write(pack(command));