Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/SessionManager.java @ 146:20beee6ca31a
*** empty log message ***
author | pin |
---|---|
date | Wed, 27 Aug 2008 23:14:39 +0900 |
parents | 0bf7f8d0f5f7 |
children | 6a5fe529b192 |
line wrap: on
line diff
--- a/rep/SessionManager.java Wed Aug 27 23:01:40 2008 +0900 +++ b/rep/SessionManager.java Wed Aug 27 23:14:39 2008 +0900 @@ -20,7 +20,10 @@ import rep.channel.REPServerSocketChannel; import rep.channel.REPSocketChannel; +import rep.channel.SelectionKeySimulator; +import rep.channel.SelectorSimulator; import rep.handler.PacketSet; +import rep.handler.REPHandler; import rep.simulator.REPSelector; import rep.xml.SessionXMLDecoder; import rep.xml.SessionXMLEncoder; @@ -62,7 +65,6 @@ } public void openSelector() throws IOException{ - //selector = Selector.open(); selector = REPSelector.open(); } @@ -91,23 +93,25 @@ } private void select() throws IOException { - for(SelectionKey key : selector.selectedKeys()){ + for(SelectionKeySimulator key : selector.selectedKeys()){ if(key.isAcceptable()){ /*** serverChannelはenableになったSelectionKeyのchannel ***/ - ServerSocketChannel serverChannel = (ServerSocketChannel)key.channel(); - SocketChannel channel = serverChannel.accept(); //keyからchannelを取って、accept + REPServerSocketChannel serverChannel = (REPServerSocketChannel)key.channel(); + REPSocketChannel channel = serverChannel.accept(); //keyからchannelを取って、accept registerChannel (selector, channel, SelectionKey.OP_READ); channel = null; }else if(key.isReadable()){ - REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>)key.channel(); - REPPacketReceive receive = new REPPacketReceive(channel); - receive.setkey(key); - REPCommand receivedCommand = receive.unpackUConv(); - manage(channel, receivedCommand); +// REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>)key.channel(); +// REPPacketReceive receive = new REPPacketReceive(channel); +// receive.setkey(key); +// REPCommand receivedCommand = receive.unpackUConv(); +// manage(channel, receivedCommand); + REPHandler handler = (REPHandler)key.attachment(); + handler.handle(key); }else if(key.isConnectable()){ System.out.println("Connectable");