Mercurial > hg > RemoteEditor > REPSessionManager
changeset 282:c410eda661e8
*** empty log message ***
author | kono |
---|---|
date | Sat, 27 Sep 2008 23:30:37 +0900 |
parents | c3969dd625b2 |
children | b864d2f60102 |
files | rep/channel/NetworkSimulator.java rep/channel/REPServerSocket.java rep/channel/SelectionKeySimulator.java rep/channel/ServerChannelSimulator.java test/sematest/TestSessionManager.java |
diffstat | 5 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/channel/NetworkSimulator.java Sat Sep 27 22:55:13 2008 +0900 +++ b/rep/channel/NetworkSimulator.java Sat Sep 27 23:30:37 2008 +0900 @@ -1,5 +1,6 @@ package rep.channel; +import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.HashMap; import java.util.LinkedList; @@ -36,7 +37,7 @@ } /* */ - synchronized public void listen(SocketAddress ip, ServerChannelSimulator<P> scs) { + synchronized public void listen(InetSocketAddress ip, ServerChannelSimulator<P> scs) { serverList.add(new ServerData<P>(ip, scs)); logger.writeLog("listen", 1); printAllState(); @@ -46,7 +47,8 @@ logger.writeLog("connecting..", 1); for (ServerData<P> sd0: serverList){ // ANY address (0.0.0.0/0.0.0.0) should be considered. - if (!sd0.IP.equals(ip)) continue; + if (sd0.IP.getAddress().isAnyLocalAddress()) { + } else if (!sd0.IP.equals(ip)) continue; ChannelSimulator<P> CHserver = new ChannelSimulator<P>(); CHserver.setOtherEnd(CHclient); @@ -64,23 +66,21 @@ } /** for DEBUG methods. */ - synchronized void printAllState(){ - synchronized (logger){ - logger.writeLog("NetworkSimulator State:"); + void printAllState(){ + String log = "NetworkSimulator State:"; for (ServerData<P> sd: serverList){ - logger.writeLog("\tSessionManager(ip="+sd.IP.toString()+"): "); - //writeLog("\tacceptWaitingList="+sd.acceptWaitingList.size()); - printChannelList(sd.connectedListC); - //writeLog("\testablishedList="+sd.establishedList.size()); + log += "\tSessionManager(ip="+sd.IP.toString()+"): "; + log += channelList(sd.connectedListC); } - } + logger.writeLog(log); } - synchronized void printChannelList(LinkedList<ChannelSimulator<P>> list){ + + String channelList(LinkedList<ChannelSimulator<P>> list){ String tmp = ""; for (ChannelSimulator<P> ch: list){ tmp += ch.toString()+" "; } - logger.writeLog("\t"+tmp); + return "\t"+tmp; } @@ -98,13 +98,13 @@ class ServerData<P> { //int virtualIP; - SocketAddress IP; + InetSocketAddress IP; //SelectorSimulator<P> selector; ServerChannelSimulator<P> scs; LinkedList<ChannelSimulator<P>> connectedListS; LinkedList<ChannelSimulator<P>> connectedListC; - ServerData(SocketAddress ip, ServerChannelSimulator<P> _scs){ + ServerData(InetSocketAddress ip, ServerChannelSimulator<P> _scs){ IP = ip; //selector = _selector; scs = _scs;
--- a/rep/channel/REPServerSocket.java Sat Sep 27 22:55:13 2008 +0900 +++ b/rep/channel/REPServerSocket.java Sat Sep 27 23:30:37 2008 +0900 @@ -2,6 +2,7 @@ import java.io.IOException; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.SocketAddress; import java.nio.channels.ServerSocketChannel; @@ -16,7 +17,7 @@ } public void bind(SocketAddress ip){ - scs.bind(ip); + scs.bind((InetSocketAddress)ip); } @Override
--- a/rep/channel/SelectionKeySimulator.java Sat Sep 27 22:55:13 2008 +0900 +++ b/rep/channel/SelectionKeySimulator.java Sat Sep 27 23:30:37 2008 +0900 @@ -21,6 +21,7 @@ channel = k.channel(); interestOpt = k.interestOps(); selector = k.selector(); + attach(k.attachment()); }
--- a/rep/channel/ServerChannelSimulator.java Sat Sep 27 22:55:13 2008 +0900 +++ b/rep/channel/ServerChannelSimulator.java Sat Sep 27 23:30:37 2008 +0900 @@ -1,6 +1,7 @@ package rep.channel; import java.io.IOException; +import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.SocketAddress; import java.nio.channels.ClosedChannelException; @@ -15,7 +16,7 @@ public class ServerChannelSimulator<P>extends REPServerSocketChannel<P> { protected NetworkSimulator<P> ns; //public REPServerSocket<REPSocketChannel<P>> socket; - protected SocketAddress IP; + protected InetSocketAddress IP; protected Queue<ChannelSimulator<P>> acceptQ; protected Object lock; protected boolean isBlocking; @@ -30,7 +31,7 @@ acceptQ = new LinkedList<ChannelSimulator<P>>(); } - public void bind(SocketAddress ip){ + public void bind(InetSocketAddress ip){ IP = ip; }
--- a/test/sematest/TestSessionManager.java Sat Sep 27 22:55:13 2008 +0900 +++ b/test/sematest/TestSessionManager.java Sat Sep 27 23:30:37 2008 +0900 @@ -94,7 +94,7 @@ } public static void main(String[] args){ - REPServerSocketChannel.isSimulation = false; + REPServerSocketChannel.isSimulation = true; TestSessionManager test = new TestSessionManager(1, 0, 2); logger.setLogLevel(5); test.startTest();