144
|
1 package rep.handler;
|
|
2
|
|
3 import rep.REPCommand;
|
|
4 import rep.SessionManager;
|
|
5 import rep.channel.ChannelSimulator;
|
|
6 import rep.channel.REPSocketChannel;
|
|
7 import rep.channel.SelectionKeySimulator;
|
|
8
|
|
9 public class REPHandlerImpl implements REPHandler {
|
|
10
|
|
11 private SessionManager manager;
|
|
12
|
|
13
|
|
14 public REPHandlerImpl(SessionManager manager) {
|
|
15 this.manager = manager;
|
|
16 }
|
|
17
|
|
18 public void handle(SelectionKeySimulator key) {
|
|
19 REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>) key.channel();
|
|
20 REPCommand packet = channel.read();
|
|
21 REPCommand command = packet;
|
|
22 manager.manage(channel, command);
|
|
23 }
|
|
24
|
|
25 }
|