annotate rep/SelectableEditorChannel.java @ 84:54334d83194a

*** empty log message ***
author pin
date Fri, 21 Dec 2007 16:03:04 +0900
parents 2d4c2c19d2d0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
1 package rep;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
2
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
3 import java.io.IOException;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
4 import java.nio.channels.ClosedChannelException;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
5 import java.nio.channels.SelectableChannel;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
6 import java.nio.channels.SelectionKey;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
7 import java.nio.channels.Selector;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
8 import java.nio.channels.SocketChannel;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
9 import java.nio.channels.spi.SelectorProvider;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
10
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
11 public class SelectableEditorChannel extends SelectableChannel{
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
12
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
13 private SocketChannel channel;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
14 private REPPacketSend repsend;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
15 private REPPacketReceive reprec;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
16
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
17 public SelectableEditorChannel(SocketChannel channel){
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
18 this.channel = channel;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
19 repsend = new REPPacketSend(channel);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
20 reprec = new REPPacketReceive(channel);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
21
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
22 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
23
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
24 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
25 public Object blockingLock() {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
26 return channel.blockingLock();
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
27 //return null;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
28 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
29
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
30 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
31 public SelectableChannel configureBlocking(boolean block) throws IOException {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
32 return channel.configureBlocking(block);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
33 //return null;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
34 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
35
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
36 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
37 public boolean isBlocking() {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
38
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
39 return channel.isBlocking();
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
40 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
41
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
42 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
43 public boolean isRegistered() {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
44 return channel.isRegistered();
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
45 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
46
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
47 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
48 public SelectionKey keyFor(Selector sel) {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
49 return channel.keyFor(sel);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
50 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
51
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
52 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
53 public SelectorProvider provider() {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
54 return channel.provider();
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
55 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
56
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
57 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
58 public SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
59 return channel.register(sel, ops, att);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
60 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
61
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
62 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
63 public int validOps() {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
64 return channel.validOps();
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
65 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
66
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
67 @Override
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
68 protected void implCloseChannel() throws IOException {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
69
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
70 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
71
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
72 public void putPacket(REPCommand comm){
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
73 repsend.send(comm);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
74 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
75 public REPCommand getPacket(){
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
76 REPCommand command = reprec.unpack();
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
77 return command;
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
78 }
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
79
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
80 //public void setIO(SocketChannel channel) {
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
81 // repsend = new REPPacketSend(channel);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
82 // reprec = new REPPacketReceive(channel);
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
83 //}
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
84
2d4c2c19d2d0 *** empty log message ***
pin
parents:
diff changeset
85 }