Mercurial > hg > RemoteEditor > REPSessionManager
changeset 275:3be92eb54b1c
*** empty log message ***
author | kono |
---|---|
date | Wed, 24 Sep 2008 17:31:57 +0900 |
parents | ad487e63e3c8 |
children | 6d172579a78d |
files | rep/Editor.java rep/Session.java rep/channel/REPSelectionKey.java |
diffstat | 3 files changed, 12 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/Editor.java Wed Sep 24 15:49:09 2008 +0900 +++ b/rep/Editor.java Wed Sep 24 17:31:57 2008 +0900 @@ -100,7 +100,7 @@ sentList.remove(0); return true; }else{ - System.out.println("error:Editor.checkReturnedCommand()"); + System.err.println("error:Editor.checkReturnedCommand()"); } } return false;
--- a/rep/Session.java Wed Sep 24 15:49:09 2008 +0900 +++ b/rep/Session.java Wed Sep 24 17:31:57 2008 +0900 @@ -1,8 +1,11 @@ package rep; +import java.nio.channels.SelectionKey; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import rep.channel.REPSelectionKey; import rep.channel.REPSocketChannel; public class Session { @@ -54,9 +57,11 @@ public boolean deleteEditor(REPSocketChannel<REPCommand> channel) { boolean flag = false; - for(Editor editor : editorList){ - if(editor.getChannel() == channel) { - editorList.remove(editor); + + for (Iterator<Editor> it = editorList.iterator();it.hasNext(); ) { + Editor e = it.next(); + if (e.getChannel()==channel) { + it.remove(); // to avoid concurrent modification flag = true; } }
--- a/rep/channel/REPSelectionKey.java Wed Sep 24 15:49:09 2008 +0900 +++ b/rep/channel/REPSelectionKey.java Wed Sep 24 17:31:57 2008 +0900 @@ -30,38 +30,10 @@ @Override public SelectableChannel channel() { if (REPServerSocketChannel.isSimulation) return key.channel(); - if (key.isAcceptable()) { - //System.err.println("Accept selectionKey.channel = "+key.channel()); - SelectableChannel sc = key.channel(); - SelectableChannel rsc = REPSocketChannel.channels.get(sc); - return rsc; - } else if (key.isReadable()) { - //System.err.println("Read selectionKey.channel = "+key.channel()); - SelectableChannel sc = key.channel(); - SelectableChannel rsc = REPSocketChannel.channels.get(sc); - return rsc; - } - return null; - + SelectableChannel sc = key.channel(); + SelectableChannel rsc = REPSocketChannel.channels.get(sc); + return rsc; } -// -// public SelectableChannel channel(REPPack<P>packer) { -// if (REPServerSocketChannel.isSimulation) return key.channel(); -// if (key.isAcceptable()) { -// //System.err.println("AcceptP selectionKey.channel = "+key.channel()); -// SelectableChannel sc = key.channel(); -// SelectableChannel rsc = REPSocketChannel.channels.get(sc); -// if (rsc!=null) return rsc; -// return new REPServerSocketChannel<P>(key.channel(),packer); -// } else if (key.isReadable()) { -// //System.err.println("ReadP selectionKey.channel = "+key.channel()); -// SelectableChannel sc = key.channel(); -// SelectableChannel rsc = REPSocketChannel.channels.get(sc); -// if (rsc!=null) return rsc; -// return new REPSocketChannel<P>(key.channel(),packer); -// } -// return null; -// } @Override public int interestOps() {