changeset 200:2f0a0448de6b

*** empty log message ***
author pin
date Sat, 30 Aug 2008 10:50:14 +0900
parents 456ba58cd042
children 0beb2bcfefe2
files rep/SessionManager.java
diffstat 1 files changed, 32 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/rep/SessionManager.java	Sat Aug 30 10:18:04 2008 +0900
+++ b/rep/SessionManager.java	Sat Aug 30 10:50:14 2008 +0900
@@ -193,10 +193,12 @@
 			session.hasOwner(true);
 			sessionList.add(new Session(sid, editor));
 
+			//リストのコピーをGUIに渡す
+			LinkedList<Session> sList = new LinkedList<Session>(sessionList);
+			LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
 			//GUIに反映
-			//gui.update();ぐらいで
-			gui.setComboSession(session.getSID(), session.getName());
-			gui.setComboEditor(editor.getEID(), editor.getChannel());
+			Runnable doRun = new DoGUIUpdate(sList, eList, gui);
+			SwingUtilities.invokeLater(doRun);
 
 			//エディタにAckを送信
 			sendCommand.setCMD(REP.SMCMD_PUT_ACK);
@@ -317,24 +319,31 @@
 			break;
 
 		case REP.SMCMD_UPDATE:
-
+		{
 			SessionXMLDecoder decoder3 = new SessionXMLDecoder();
 			SessionList receivedSessionList3 = decoder3.decode(receivedCommand.string);
 
-			//SessionListへ追加し変換テーブルを生成する。
-			//sessionlist.update(channel, receivedSessionList3);
-			sessionList.add(new Session(new Editor(channel)));
-			
+			//UPDATEコマンドにより送られてきたSessionの情報を追加する
+			LinkedList<Session> list = receivedSessionList3.getList();
+			for(Session session : list){
+				session.getEditorList().get(0).setChannel(channel);
+				sessionList.add(session);
+			}
+
+			//他のSessionManagerへ中継する
 			smList.sendExcept(channel, receivedCommand);
 
-			for(Session session3 : receivedSessionList3.getList()){
-				//gui.update();
-				gui.setComboSession(session3.getSID(), session3.getName());
-			}
-
+			//リストのコピーをGUIに渡す
+			LinkedList<Session> sList = new LinkedList<Session>(sessionList);
+			LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
+			//GUIに反映
+			Runnable doRun = new DoGUIUpdate(sList, eList, gui);
+			SwingUtilities.invokeLater(doRun);
+		}
 			break;
 
 		case REP.SMCMD_UPDATE_ACK:
+		{
 			if(receivedCommand.sid > sessionList.size()){
 				Editor editor = new Editor(channel);
 				editor.setName(receivedCommand.string);
@@ -343,13 +352,20 @@
 				session.addEditor(editor);
 
 				sessionList.add(session);
-
-				gui.setComboSession(session.getSID(), session.getName());
+				
+				//リストのコピーをGUIに渡す
+				LinkedList<Session> sList = new LinkedList<Session>(sessionList);
+				LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
+				//GUIに反映
+				Runnable doRun = new DoGUIUpdate(sList, eList, gui);
+				SwingUtilities.invokeLater(doRun);
 			}
 			smList.sendToSlave(receivedCommand);
+		}
 			break;
 
 		case REP.SMCMD_CH_MASTER:
+		{
 			//maxHost を設定。
 			if(setMaxHost(channel, receivedCommand.string)){
 				sendCommand = new REPCommand();
@@ -357,6 +373,7 @@
 				sendCommand.setString(maxHost);
 				smList.sendExcept(channel, sendCommand);
 			}
+		}
 			break;
 
 		default: