Mercurial > hg > RemoteEditor > Eclipse
changeset 70:9c19d6d61a03
refactor
author | kent |
---|---|
date | Thu, 08 Nov 2007 15:11:13 +0900 |
parents | 3c9b8371681d |
children | eda73e0a0388 |
files | src/pathfinder/NetworkSimulator.java src/pathfinder/SeMaEmulator.java src/pathfinder/TestNetwork.java |
diffstat | 3 files changed, 14 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pathfinder/NetworkSimulator.java Thu Nov 08 14:19:47 2007 +0900 +++ b/src/pathfinder/NetworkSimulator.java Thu Nov 08 15:11:13 2007 +0900 @@ -15,6 +15,10 @@ connectedList = new LinkedList<ChannelSimulator<P>>(); } + /** + * Establish connection. It's called by SeMa. + * @return + */ public ChannelSimulator<P> accept(){ ChannelSimulator<P> cs = acceptList.poll(); if (cs==null) return null; @@ -22,6 +26,12 @@ connectedList.offer(cs); return cs.getServerChannel(); } + + /** + * Request to connect. + * Client editor use this method to connect SeMa. + * @param cs + */ public void connect(ChannelSimulator<P> cs){ acceptList.offer(cs); }
--- a/src/pathfinder/SeMaEmulator.java Thu Nov 08 14:19:47 2007 +0900 +++ b/src/pathfinder/SeMaEmulator.java Thu Nov 08 15:11:13 2007 +0900 @@ -11,12 +11,7 @@ ns = _ns; csList = new ArrayList<ChannelSimulator<P>>(); } -/* - public ChannelSimulator<P> addChannelSimulator(ChannelSimulator<P> cs){ - csList.add(cs); - return cs; - } -*/ + /** * Check whether NetworkSimulator hold waiting connections. */ @@ -27,18 +22,9 @@ csList.add(cs); return true; } - public void init(){ + public void waitClient(){ while(csList.size()<2){ checkAccept(); - /* - try { - Thread.sleep(10); - } catch (InterruptedException e) { - e.printStackTrace(); - break; - } - */ - //Thread.yield(); } } @@ -46,7 +32,7 @@ int i=0; P packet; - init(); + waitClient(); System.out.println("SessionManager was initialized."); /* Main Loop */
--- a/src/pathfinder/TestNetwork.java Thu Nov 08 14:19:47 2007 +0900 +++ b/src/pathfinder/TestNetwork.java Thu Nov 08 15:11:13 2007 +0900 @@ -11,7 +11,7 @@ private int N_editor; public static void main(String [] arg) { - TestNetwork test = new TestNetwork(2); + TestNetwork test = new TestNetwork(4); test.startTest(); }