changeset 191:dbf59f82273e

*** empty log message ***
author pin
date Fri, 29 Aug 2008 18:52:36 +0900
parents 63701e2a2fe8
children 6fb97c7a0b42
files rep/SessionManager.java
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/rep/SessionManager.java	Fri Aug 29 18:51:37 2008 +0900
+++ b/rep/SessionManager.java	Fri Aug 29 18:52:36 2008 +0900
@@ -40,7 +40,7 @@
 	//private SessionList sessionlist;
 	private LinkedList<Session> sessionList;
 	private SessionManagerGUI gui;
-	private Selector selector;
+	private REPSelector selector;
 	private SessionManagerList smList;
 	private String myHost;
 	private boolean isMaster = true;
@@ -57,11 +57,11 @@
 	static final int DEFAULT_PORT = 8766;
 	
 	public SessionManager(int port) {
-		gui = new SessionManagerGUI(this);
+		
 	}
 	
 	public void openSelector() throws IOException{
-		selector = REPSelector.open();
+		selector = REPSelector.create();
 	}
 	
 	public void init(int port) throws InterruptedException, IOException {
@@ -70,7 +70,8 @@
 		ssc.configureBlocking(false);	//reuse address 必須
 		ssc.socket().setReuseAddress(true);
 		ssc.socket().bind(new InetSocketAddress(port));
-		ssc.register(selector, SelectionKey.OP_ACCEPT);
+		//ssc.register(selector, SelectionKey.OP_ACCEPT);
+		registerChannel(selector, ssc, SelectionKey.OP_ACCEPT);
 
 		
 		//sessionlist = new SessionList();
@@ -81,7 +82,7 @@
 		packetSetList = new LinkedList<PacketSet>();
 		
 		// main loop
-		mainLoop();
+		//mainLoop();
 	}
 
 	private void mainLoop() throws IOException {
@@ -432,6 +433,9 @@
 	}
 
 	public static void main(String[] args) throws InterruptedException, IOException {
+
+		REPServerSocketChannel.isSimulation = true;
+		
 		int port = DEFAULT_PORT;
 		int port_s = DEFAULT_PORT;
 		//System.setProperty("file.encoding", "UTF-8");
@@ -443,16 +447,16 @@
 		send_port = port_s;
 		SessionManager sm = new SessionManager(port);
 		sm.openSelector();
-		sm.openWindow();
 		sm.init(port);
+		sm.startGUI(sm);
 		sm.mainLoop();
+
 	}
 
-	private void openWindow() {
+	private void startGUI(SessionManager sm) {
+		gui = new SessionManagerGUI(this);
 		Thread th = new Thread( gui ); 
 		th.start();
-		gui.addConnectionListener(this);
-		gui.addREPActionListener(this);
 	}
 
 	public void connectSession(String host) {