Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/Session.java @ 275:3be92eb54b1c
*** empty log message ***
author | kono |
---|---|
date | Wed, 24 Sep 2008 17:31:57 +0900 |
parents | ad487e63e3c8 |
children | a549bd4dadb8 |
comparison
equal
deleted
inserted
replaced
274:ad487e63e3c8 | 275:3be92eb54b1c |
---|---|
1 package rep; | 1 package rep; |
2 | 2 |
3 import java.nio.channels.SelectionKey; | |
4 import java.util.Iterator; | |
3 import java.util.LinkedList; | 5 import java.util.LinkedList; |
4 import java.util.List; | 6 import java.util.List; |
5 | 7 |
8 import rep.channel.REPSelectionKey; | |
6 import rep.channel.REPSocketChannel; | 9 import rep.channel.REPSocketChannel; |
7 | 10 |
8 public class Session { | 11 public class Session { |
9 private Editor masterEditor; | 12 private Editor masterEditor; |
10 private int sessionID; | 13 private int sessionID; |
52 editorList.add(editor); | 55 editorList.add(editor); |
53 } | 56 } |
54 | 57 |
55 public boolean deleteEditor(REPSocketChannel<REPCommand> channel) { | 58 public boolean deleteEditor(REPSocketChannel<REPCommand> channel) { |
56 boolean flag = false; | 59 boolean flag = false; |
57 for(Editor editor : editorList){ | 60 |
58 if(editor.getChannel() == channel) { | 61 for (Iterator<Editor> it = editorList.iterator();it.hasNext(); ) { |
59 editorList.remove(editor); | 62 Editor e = it.next(); |
63 if (e.getChannel()==channel) { | |
64 it.remove(); // to avoid concurrent modification | |
60 flag = true; | 65 flag = true; |
61 } | 66 } |
62 } | 67 } |
63 return flag; | 68 return flag; |
64 } | 69 } |