Mercurial > hg > Members > kazz > WebSocket
changeset 3:fe4469e7915a default tip
change remove() to key.cancel()
author | kazz |
---|---|
date | Sat, 22 Jan 2011 15:04:49 +0900 |
parents | d5d2ca53a832 |
children | |
files | src/IOHandler.java |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/IOHandler.java Sat Jan 22 05:30:20 2011 +0900 +++ b/src/IOHandler.java Sat Jan 22 15:04:49 2011 +0900 @@ -9,7 +9,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; - public class IOHandler implements Handler { public static int BUFFERSIZE = 8192; public HashMap<String, String> map = new HashMap<String, String>(); @@ -17,7 +16,7 @@ @Override public void handle(SelectionKey key) { if (!key.isReadable()) { - key.selector().keys().remove(key); + key.cancel(); return; } SocketChannel sChannel = (SocketChannel)key.channel(); @@ -43,6 +42,8 @@ ByteBuffer response = generateResponse(resCode); sChannel.write(response); System.out.println("sent response"); + } else { + key.cancel(); } } catch (IOException e) { e.printStackTrace();