diff rep/SessionManager.java @ 198:ff3fcdcccc85

*** empty log message ***
author pin
date Sat, 30 Aug 2008 01:11:27 +0900
parents 6fb97c7a0b42
children 456ba58cd042
line wrap: on
line diff
--- a/rep/SessionManager.java	Sat Aug 30 00:00:51 2008 +0900
+++ b/rep/SessionManager.java	Sat Aug 30 01:11:27 2008 +0900
@@ -12,6 +12,8 @@
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
+import javax.swing.SwingUtilities;
+
 import rep.channel.REPServerSocketChannel;
 import rep.channel.REPSocketChannel;
 import rep.handler.PacketSet;
@@ -21,40 +23,37 @@
 import rep.channel.REPSelector;
 import rep.xml.SessionXMLDecoder;
 import rep.xml.SessionXMLEncoder;
-
+import rep.channel.REPSelectionKey;
+/*
 //+-------+--------+--------+-------+--------+---------+------+
 //| cmd   | session| editor | seqid | lineno | textsiz | text |
 //|       | id     | id     |       |        |         |      |
 //+-------+--------+--------+-------+--------+---------+------+
 //o-------header section (network order)-------------o
-/*int cmd;	// command
+int cmd;	// command
 int sid;	// session ID : uniqu to editing file
 int eid;	// editor ID : owner editor ID = 1。Session に対して unique
 int seqno;	// Sequence number : sequence number はエディタごとに管理
 int lineno;	// line number
 int textsize;   // textsize : bytesize
-byte[] text;*/
+byte[] text;
+*/
 
 public class SessionManager implements ConnectionListener, REPActionListener{
 	
-	
-	//private SessionList sessionlist;
 	private LinkedList<Session> sessionList;
 	private SessionManagerGUI gui;
-	private REPSelector selector;
+	private REPSelector<REPCommand> selector;
 	private SessionManagerList smList;
 	private String myHost;
 	private boolean isMaster = true;
-	//private EditorList  ownEditorList;
 	private List<Editor> editorList;
 	private String maxHost;
 	private boolean isSimulation;
 	private List<PacketSet> packetSetList;
 	private BlockingQueue<SessionManagerEvent> waitingQueue;
-	//private List<SessionManagerNode> managerList;
 	private static int temp_port;
 	private static int send_port;
-	
 	static final int DEFAULT_PORT = 8766;
 	
 	public SessionManager(int port) {
@@ -118,7 +117,7 @@
 		if(e != null) {
 			e.exec();
 		}
-		for(SelectionKey key : selector.selectedKeys()){
+		for(REPSelectionKey<REPCommand> key : selector.selectedKeys1()){
 			if(key.isAcceptable()){
 				/*** serverChannelはenableになったSelectionKeyのchannel ***/
 				REPServerSocketChannel serverChannel = (REPServerSocketChannel)key.channel();
@@ -161,12 +160,14 @@
 			editor.setHost(myHost);
 			editorList.add(editor);
 
+			//リストのコピーをGUIに渡す
+			LinkedList<Session> sList = new LinkedList<Session>(sessionList);
+			LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
 			//GUIに反映
-			//gui.setComboEditor(editor.getEID(), channel);
-			gui.update();
+			Runnable doRun = new DoGUIUpdate(sList, eList, gui);
+			SwingUtilities.invokeLater(doRun);
 		}
 
-
 		break;
 
 		case REP.SMCMD_JOIN_ACK: