Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/channel/REPSocketChannel.java @ 184:3c82100cdadd
*** empty log message ***
author | kent |
---|---|
date | Fri, 29 Aug 2008 16:38:11 +0900 |
parents | 72252e970a8b |
children | be219ba8b39c |
line wrap: on
line diff
--- a/rep/channel/REPSocketChannel.java Fri Aug 29 13:40:29 2008 +0900 +++ b/rep/channel/REPSocketChannel.java Fri Aug 29 16:38:11 2008 +0900 @@ -9,26 +9,17 @@ import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; -import java.nio.channels.ServerSocketChannel; import java.nio.channels.spi.SelectorProvider; public class REPSocketChannel<P> extends SelectableChannel{ private SocketChannel sc; - private REPUnpack<P> unpack; private REPPack<P> pack; - public REPSocketChannel(SocketChannel channel) { + public REPSocketChannel(SocketChannel channel, REPPack<P> packer) { sc = channel; + pack = packer; } - - public void setUnpack(REPUnpack<P> _unpack){ - unpack = _unpack; - } - public void setPack(REPPack<P> _pack){ - pack = _pack; - } - @Override public Object blockingLock() { @@ -96,7 +87,7 @@ } public P read() throws IOException{ - return unpack.unpackUConv(sc); + return pack.unpackUConv(sc); } public boolean write(P p){ ByteBuffer bb = pack.packUConv(p); @@ -110,11 +101,12 @@ } } - public static <T> REPSocketChannel<T> create() throws IOException { + public static <T> REPSocketChannel<T> create(REPPack<T> packer) throws IOException { if (REPServerSocketChannel.isSimulation) { return new ChannelSimulator<T>(); } else { - return new REPSocketChannel<T>(SocketChannel.open()); + REPSocketChannel<T> rsc = new REPSocketChannel<T>(SocketChannel.open(), packer); + return rsc; } }