316
|
1 package rep.handler;
|
|
2
|
|
3 import java.io.IOException;
|
|
4
|
|
5 import rep.REPCommand;
|
|
6 import rep.SessionManager;
|
|
7 import rep.channel.REPSelectionKey;
|
|
8 import rep.channel.REPSocketChannel;
|
|
9
|
|
10 public class REPEditorHandler implements REPHandler {
|
|
11
|
|
12 private SessionManager manager;
|
|
13
|
|
14
|
|
15 public REPEditorHandler(SessionManager manager) {
|
|
16 this.manager = manager;
|
|
17 }
|
|
18
|
|
19 public void handle(REPSelectionKey<REPCommand> key) throws IOException {
|
|
20 REPSocketChannel<REPCommand> channel = key.channel1();
|
|
21 REPCommand command = channel.read();
|
|
22 System.out.println("REPHandlerImpl.handle() read : command = " + command +" from "+channel);
|
|
23
|
|
24 manager.manage(channel, command);
|
|
25 }
|
|
26
|
|
27 public void cancel(REPSocketChannel<REPCommand> socketChannel) {
|
|
28 manager.remove(socketChannel);
|
|
29 }
|
|
30
|
|
31
|
|
32 }
|