Mercurial > hg > FederatedLinda
annotate src/fdl/AcceptHandler.java @ 19:0243987383b7
Meta Protocol Engine and sample implementation of event logger.
ComDebug_Client needs fixes.
author | kono |
---|---|
date | Tue, 19 Aug 2008 05:33:32 +0900 |
parents | 609b288f47f9 |
children | 56e015e8f5dc |
rev | line source |
---|---|
0 | 1 |
2 package fdl; | |
3 import java.io.IOException; | |
4 import java.nio.channels.ClosedChannelException; | |
5 import java.nio.channels.SelectionKey; | |
6 import java.nio.channels.ServerSocketChannel; | |
7 import java.nio.channels.SocketChannel; | |
8 | |
17 | 9 public class AcceptHandler implements TupleHandler { |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
10 |
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
11 public TupleSpace tupleSpace; |
0 | 12 |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
13 public AcceptHandler(TupleSpace tupleSpace) { |
0 | 14 // 読みこんだデータを格納するためのリストの初期化 |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
15 this.tupleSpace = tupleSpace; |
0 | 16 } |
17 | |
18 public void handle(SelectionKey key) | |
19 throws ClosedChannelException, IOException { | |
20 ServerSocketChannel serverChannel | |
21 = (ServerSocketChannel)key.channel(); | |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
22 |
0 | 23 // アクセプト処理 |
24 SocketChannel channel = serverChannel.accept(); | |
25 channel.configureBlocking(false); | |
3 | 26 System.out.println("Server: accepted "+channel.socket()); |
27 | |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
28 tupleSpace.newUser(); |
0 | 29 |
30 // 入出力用のハンドラを生成し,アタッチする | |
31 // 監視する操作は読み込みのみ | |
32 channel.register(key.selector(), | |
33 SelectionKey.OP_READ, | |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
34 new IOHandler(tupleSpace,key)); |
3 | 35 } |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
36 |
0 | 37 } |