9
|
1 package rep;
|
|
2
|
|
3 import java.nio.channels.SocketChannel;
|
|
4 import java.nio.channels.spi.SelectorProvider;
|
|
5
|
|
6 public abstract class EditorChannel extends SocketChannel {
|
|
7
|
11
|
8 private REPPacketSend repsend;
|
|
9 private REPPacketReceive reprec;
|
|
10
|
9
|
11 protected EditorChannel(SelectorProvider provider) {
|
|
12 super(provider);
|
|
13 }
|
|
14
|
|
15 public void putPacket(REPCommand comm){
|
|
16 repsend.send(comm);
|
|
17 }
|
11
|
18
|
9
|
19 public REPCommand getPacket(){
|
|
20 REPCommand command = reprec.unpack();
|
|
21 return command;
|
|
22 }
|
|
23
|
|
24 public void setIO(SocketChannel channel) {
|
|
25 repsend = new REPPacketSend(channel);
|
|
26 reprec = new REPPacketReceive(channel);
|
|
27 }
|
11
|
28
|
|
29 public void setIO() {
|
|
30 repsend = new REPPacketSend(this);
|
|
31 reprec = new REPPacketReceive(this);
|
|
32 }
|
9
|
33
|
|
34 }
|