316
|
1 package rep;
|
|
2
|
|
3 import rep.channel.REPLogger;
|
|
4 import rep.channel.REPSocketChannel;
|
317
|
5 import rep.handler.PacketSet;
|
316
|
6
|
319
|
7 public class Forwarder extends EditorPlus {
|
|
8 int seq = 0;
|
|
9 Forwarder next;
|
316
|
10 // REPCommands we sent to the next editor
|
|
11 final int limit=100;
|
|
12 REPLogger ns = REPLogger.singleton();
|
317
|
13 SessionManager manager;
|
316
|
14
|
317
|
15 public Forwarder(SessionManager manager) {
|
|
16 this.manager = manager;
|
|
17 }
|
|
18
|
319
|
19 public int seq() {
|
|
20 return seq++;
|
316
|
21 }
|
|
22
|
|
23 public void send(REPCommand command) {
|
318
|
24 assert(command!=null);
|
327
|
25 REPCommand c = new REPCommand(command);
|
328
|
26 manager.addWriteQueue(new PacketSet(channel,null, c));
|
316
|
27 }
|
|
28
|
|
29 public REPSocketChannel<REPCommand> getChannel() {
|
319
|
30 return channel;
|
316
|
31 }
|
|
32
|
|
33 public void setChannel(REPSocketChannel<REPCommand> channel) {
|
319
|
34 this.channel = channel;
|
316
|
35 }
|
|
36
|
318
|
37 public void setQuit2(REPCommand cmd) {
|
|
38 send(cmd);
|
|
39 }
|
|
40
|
319
|
41 public void setNext(Forwarder next) {
|
|
42 this.next = next;
|
|
43 }
|
|
44
|
|
45 public Forwarder getNextForwarder() {
|
|
46 return next;
|
|
47 }
|
|
48
|
|
49 public boolean manage(REPCommand command) {
|
|
50 send(command);
|
|
51 return true;
|
|
52 }
|
|
53
|
316
|
54 } |