annotate rep/handler/REPHandlerImpl.java @ 237:c52e0e831d91

*** empty log message ***
author pin
date Sun, 31 Aug 2008 19:33:23 +0900
parents dae90ded1bcd
children 6589b148dd13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
1 package rep.handler;
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
2
155
bbd2801d8ce0 *** empty log message ***
pin
parents: 148
diff changeset
3 import java.io.IOException;
218
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
4 import java.nio.channels.SelectableChannel;
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
5
144
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
6 import rep.REPCommand;
213
4d9b32666ed2 *** empty log message ***
pin
parents: 178
diff changeset
7 import rep.REPCommandPacker;
144
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
8 import rep.SessionManager;
213
4d9b32666ed2 *** empty log message ***
pin
parents: 178
diff changeset
9 import rep.channel.REPSelectionKey;
144
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
10 import rep.channel.REPSocketChannel;
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
11
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
12 public class REPHandlerImpl implements REPHandler {
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
13
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
14 private SessionManager manager;
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
15
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
16
170
30cf7747d134 *** empty log message ***
pin
parents: 155
diff changeset
17 public REPHandlerImpl(int sid, SessionManager manager) {
144
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
18 this.manager = manager;
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
19 }
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
20
178
a097b1d619a1 *** empty log message ***
pin
parents: 170
diff changeset
21 @SuppressWarnings("unchecked")
213
4d9b32666ed2 *** empty log message ***
pin
parents: 178
diff changeset
22 public void handle(REPSelectionKey<REPCommand> key) throws IOException {
218
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
23 SelectableChannel s = key.channel();
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
24 if(!(s instanceof REPSocketChannel) ){
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
25 System.out.println("error");
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
26 }
827c439d0da4 *** empty log message ***
pin
parents: 213
diff changeset
27 REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>) key.channel(new REPCommandPacker());
237
c52e0e831d91 *** empty log message ***
pin
parents: 233
diff changeset
28 System.out.println("REPHandlerImpl.handle() : channel = " + channel);
c52e0e831d91 *** empty log message ***
pin
parents: 233
diff changeset
29
178
a097b1d619a1 *** empty log message ***
pin
parents: 170
diff changeset
30 REPCommand command = channel.read();
233
dae90ded1bcd *** empty log message ***
pin
parents: 218
diff changeset
31 System.out.println("REPHandlerImpl.handle() : command = " + command);
178
a097b1d619a1 *** empty log message ***
pin
parents: 170
diff changeset
32
144
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
33 manager.manage(channel, command);
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
34 }
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
35
0bf7f8d0f5f7 *** empty log message ***
pin
parents:
diff changeset
36 }