Mercurial > hg > RemoteEditor > REPSessionManager
changeset 269:6e0fa3415668
*** empty log message ***
author | kono |
---|---|
date | Thu, 11 Sep 2008 15:05:42 +0900 |
parents | b69d22dbc6f1 |
children | 5e0e4877465d |
files | test/ServerSample.java |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/test/ServerSample.java Thu Sep 11 15:00:16 2008 +0900 +++ b/test/ServerSample.java Thu Sep 11 15:05:42 2008 +0900 @@ -3,6 +3,7 @@ import java.nio.channels.*; import java.nio.charset.*; import java.net.*; +import java.util.Iterator; import rep.REPCommand; import rep.REPCommandPacker; @@ -37,6 +38,14 @@ // 獲得したイベントごとに処理を実行 for (REPSelectionKey<REPCommand> selectionKey : selector.selectedKeys1()) { + // java.nio だと for 文では動かないが、REPSocketChannel では動く + // + //for (Iterator<SelectionKey> it = keys.iterator();it.hasNext(); ) { + // SelectionKey k = it.next(); + // newKeys.add(new REPSelectionKey<P>(k,this)); + // it.remove(); + //} + // と書く必要がある。 // サーバの受付処理: // イベントが受付可能である場合、受け付けるべき対象があれば @@ -76,7 +85,8 @@ case -1: // クライアント側が接続を切断していた場合は、サーバも // 接続を切断。セレクタから登録を削除 - socketChannel.close(); + selectionKey.cancel(); // これは必要だと思う + socketChannel.close(); // 既にcloseされているはず break; case 0: // 読み込むべきメッセージは届いていないので処理を飛ばす