Mercurial > hg > RemoteEditor > REPSessionManager
changeset 27:2d51078d94dd
edit disconnet key.cancel and accept
author | fuchita |
---|---|
date | Fri, 09 Nov 2007 19:15:06 +0900 |
parents | ad1060ba4213 |
children | 1544f5c45dd8 |
files | rep/REPPacketReceive.java |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/REPPacketReceive.java Fri Nov 09 17:52:54 2007 +0900 +++ b/rep/REPPacketReceive.java Fri Nov 09 19:15:06 2007 +0900 @@ -2,6 +2,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.LinkedList; import java.util.StringTokenizer; @@ -12,11 +13,16 @@ private final int HEADER_SIZE = 24; //private String host; //private int port; + SelectionKey key; public REPPacketReceive(SocketChannel sc){ socketchannel = sc; } - + + public void setkey(SelectionKey key) { + this.key = key; + //key.cancel(); + } public REPCommand unpack() { @@ -26,6 +32,9 @@ try { len = socketchannel.read(header); if(len == -1){ + if(key != null){ + key.cancel(); + } socketchannel.close(); return null; }else if(len == 0){