Mercurial > hg > Members > kazz > WebSocket
changeset 2:d5d2ca53a832
dealed dispose of connection close
author | kazz |
---|---|
date | Sat, 22 Jan 2011 05:30:20 +0900 |
parents | 4c2ddaa9b998 |
children | fe4469e7915a |
files | src/IOHandler.java src/WebSocketServer.java |
diffstat | 2 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/IOHandler.java Sat Jan 22 05:01:34 2011 +0900 +++ b/src/IOHandler.java Sat Jan 22 05:30:20 2011 +0900 @@ -16,8 +16,10 @@ @Override public void handle(SelectionKey key) { - if (!key.isReadable()) + if (!key.isReadable()) { + key.selector().keys().remove(key); return; + } SocketChannel sChannel = (SocketChannel)key.channel(); ByteBuffer buffer = ByteBuffer.allocate(BUFFERSIZE); try {
--- a/src/WebSocketServer.java Sat Jan 22 05:01:34 2011 +0900 +++ b/src/WebSocketServer.java Sat Jan 22 05:30:20 2011 +0900 @@ -32,8 +32,9 @@ for (SelectionKey key : selector.selectedKeys()) { Handler handler = (Handler) key.attachment(); handler.handle(key); - selector.selectedKeys().remove(key); +// selector.selectedKeys().remove(key); } + selector.selectedKeys().clear(); } catch (IOException e) { e.printStackTrace();