144
|
1 package rep.handler;
|
|
2
|
155
|
3 import java.io.IOException;
|
178
|
4 import rep.Editor;
|
144
|
5 import rep.REPCommand;
|
313
|
6 import rep.Session;
|
144
|
7 import rep.SessionManager;
|
213
|
8 import rep.channel.REPSelectionKey;
|
155
|
9 import rep.channel.REPSocketChannel;
|
144
|
10
|
|
11 public class REPHandlerInMerge implements REPHandler {
|
|
12
|
|
13 private SessionManager manager;
|
|
14
|
|
15 public REPHandlerInMerge(SessionManager manager) {
|
|
16 this.manager = manager;
|
|
17 }
|
|
18
|
|
19
|
213
|
20 public void handle(REPSelectionKey<REPCommand> key) throws IOException {
|
178
|
21 //マージ中のエディタの前のエディタのコマンドをWaitingListに追加する
|
308
|
22 REPSocketChannel<REPCommand> channel = key.channel1();
|
273
|
23 REPCommand command = channel.read();
|
274
|
24 System.out.println("REPHandlerImpl.handle() : command = " + command);
|
308
|
25 // if (manager.isMerging(command.sid()))...
|
|
26 // 同じchannelで、merge中のsessionは一つは限らない。
|
|
27 // なので、sid をinstanceで持つのではだめ。
|
313
|
28 Session s = manager.getSession(command.sid);
|
|
29 Editor editor = s.getEditor(channel);
|
308
|
30 manager.addWaitingCommand(new PacketSet(channel, editor, command));
|
148
|
31 }
|
|
32
|
274
|
33 public void cancel(REPSocketChannel<REPCommand> socketChannel) {
|
|
34 manager.remove(socketChannel);
|
267
|
35 }
|
144
|
36 }
|