Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/channel/ServerChannelSimulator.java @ 194:be219ba8b39c
*** empty log message ***
author | kono |
---|---|
date | Fri, 29 Aug 2008 20:25:46 +0900 |
parents | 5653cf8e3c8b |
children | 4c0a94836357 |
comparison
equal
deleted
inserted
replaced
193:311847db7429 | 194:be219ba8b39c |
---|---|
2 | 2 |
3 import java.io.IOException; | 3 import java.io.IOException; |
4 import java.net.ServerSocket; | 4 import java.net.ServerSocket; |
5 import java.net.SocketAddress; | 5 import java.net.SocketAddress; |
6 import java.nio.channels.ClosedChannelException; | 6 import java.nio.channels.ClosedChannelException; |
7 import java.nio.channels.SelectableChannel; | |
7 import java.nio.channels.SelectionKey; | 8 import java.nio.channels.SelectionKey; |
9 import java.nio.channels.Selector; | |
8 import java.nio.channels.SocketChannel; | 10 import java.nio.channels.SocketChannel; |
11 import java.nio.channels.spi.SelectorProvider; | |
9 | 12 |
10 /* シミュレーションの際にコンストラクトされる REPServerSocketChannel の実装 */ | 13 /* シミュレーションの際にコンストラクトされる REPServerSocketChannel の実装 */ |
11 public class ServerChannelSimulator<P>extends REPServerSocketChannel<P>{ | 14 public class ServerChannelSimulator<P>extends REPServerSocketChannel<P> { |
12 protected NetworkSimulator<P> ns; | 15 protected NetworkSimulator<P> ns; |
13 //public REPServerSocket<REPSocketChannel<P>> socket; | 16 //public REPServerSocket<REPSocketChannel<P>> socket; |
14 protected SocketAddress IP; | 17 protected SocketAddress IP; |
15 | 18 |
16 /** Constructors. | 19 /** Constructors. |
26 | 29 |
27 public REPSocketChannel<P> accept1() /*throws IOException*/ { | 30 public REPSocketChannel<P> accept1() /*throws IOException*/ { |
28 return ns.accept(IP); | 31 return ns.accept(IP); |
29 } | 32 } |
30 | 33 |
31 @Override | |
32 public ServerSocket socket() { | 34 public ServerSocket socket() { |
33 try { | 35 try { |
34 return new REPServerSocket(this); | 36 return new REPServerSocket(this); |
35 } catch (IOException e) { | 37 } catch (IOException e) { |
36 e.printStackTrace(); | 38 e.printStackTrace(); |
37 return null; | 39 return null; |
38 } | 40 } |
39 } | 41 } |
40 | 42 |
41 @Override | |
42 protected void implCloseSelectableChannel() throws IOException { | |
43 return; | |
44 } | |
45 | |
46 @Override | |
47 protected void implConfigureBlocking(boolean block) throws IOException { | |
48 return; | |
49 } | |
50 | |
51 @Override | |
52 public SocketChannel accept() throws IOException { | |
53 // TODO Auto-generated method stub | |
54 return null; | |
55 } | |
56 | 43 |
57 | 44 |
58 public SelectionKey register(REPSelector sel, int ops, Object att) throws ClosedChannelException { | 45 public SelectionKey register(REPSelector<P> sel, int ops, Object att) throws ClosedChannelException { |
59 REPSelector selector = sel; | 46 REPSelector<P> selector = sel; |
60 ns.listen(IP, (SelectorSimulator) selector); | 47 ns.listen(IP, (SelectorSimulator) selector); |
61 return selector.register(this, ops, att); | 48 return selector.register(this, ops, att); |
62 } | 49 } |
63 | 50 |
64 public boolean isAcceptable() { | 51 public boolean isAcceptable() { |
65 return ns.canAccept(IP); | 52 return ns.canAccept(IP); |
66 } | 53 } |
67 | 54 |
55 @Override | |
56 public Object blockingLock() { | |
57 // TODO Auto-generated method stub | |
58 return null; | |
59 } | |
60 | |
61 public SelectableChannel configureBlocking(boolean block) | |
62 throws IOException { | |
63 // TODO Auto-generated method stub | |
64 return null; | |
65 } | |
66 | |
67 @Override | |
68 public boolean isBlocking() { | |
69 // TODO Auto-generated method stub | |
70 return false; | |
71 } | |
72 | |
73 @Override | |
74 public boolean isRegistered() { | |
75 // TODO Auto-generated method stub | |
76 return false; | |
77 } | |
78 | |
79 @Override | |
80 public SelectionKey keyFor(Selector sel) { | |
81 // TODO Auto-generated method stub | |
82 return null; | |
83 } | |
84 | |
85 @Override | |
86 public SelectorProvider provider() { | |
87 // TODO Auto-generated method stub | |
88 return null; | |
89 } | |
90 | |
91 @Override | |
92 public SelectionKey register(Selector sel, int ops, Object att) | |
93 throws ClosedChannelException { | |
94 // TODO Auto-generated method stub | |
95 return null; | |
96 } | |
97 | |
98 @Override | |
99 public int validOps() { | |
100 // TODO Auto-generated method stub | |
101 return 0; | |
102 } | |
103 | |
104 @Override | |
105 protected void implCloseChannel() throws IOException { | |
106 // TODO Auto-generated method stub | |
107 | |
108 } | |
109 | |
68 } | 110 } |