changeset 250:5f357ca66714

*** empty log message ***
author pin
date Thu, 04 Sep 2008 19:09:37 +0900
parents e44c1773d121
children 774c66db4939
files rep/SessionManager.java
diffstat 1 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/rep/SessionManager.java	Wed Sep 03 19:35:41 2008 +0900
+++ b/rep/SessionManager.java	Thu Sep 04 19:09:37 2008 +0900
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -37,13 +38,14 @@
 byte[] text;
 */
 
-public class SessionManager implements SessionManagerEventListener {
+public class SessionManager implements SessionManagerEventListener{
 	
 	private LinkedList<Session> sessionList;
 	private SessionManagerGUI gui;
 	private REPSelector<REPCommand> selector;
 	private SessionManagerList smList;
 	private String myHost;
+	private boolean isMaster = true;
 	private List<Editor> editorList;
 	private String maxHost;
 	private List<PacketSet> waitingCommandInMerge;
@@ -394,6 +396,10 @@
 		//リストのコピーをGUIに渡す
 		LinkedList<Session> sList = new LinkedList<Session>(sessionList);
 		LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
+		for(Editor editor : eList){
+			System.out.println("SessionManager.guiUpdate() : channel = " + editor.getChannel());
+		}
+		
 		//GUIに反映
 		Runnable doRun = new DoGUIUpdate(sList, eList, gui);
 		SwingUtilities.invokeLater(doRun);
@@ -476,7 +482,7 @@
 
 	}
 
-	private void startGUI(SessionManager sm) {
+	public void startGUI(SessionManager sm) {
 		gui = new SessionManagerGUI();
 		Thread th = new Thread( gui ); 
 		th.start();
@@ -524,7 +530,7 @@
 		smList.add(channel);
 	}
 
-	private String getLocalHostName(REPSocketChannel<REPCommand> channel) {
+	private String getLocalHostName(REPSocketChannel channel) {
 		String host = null;
 		host = channel.socket().getLocalAddress().getHostName();
 		return host;
@@ -547,12 +553,14 @@
 //		selector.wakeup();
 //	}
 
-	public void selectSession(SelectButtonEvent selectButtonEvent) {
-		REPSocketChannel<REPCommand> channel = selectButtonEvent.getEditorChannel();
-		int sid = selectButtonEvent.getSID();
+	public void selectSession(SelectButtonEvent event) {
+		REPSocketChannel<REPCommand> channel = event.getEditorChannel();
+		int sid = event.getSID();
+		int eid = event.getEID();
 		Session session = getSession(sid);
 		
-		Editor editor = getEditor(channel);
+		//Editor editor = getEditor(channel);
+		Editor editor = editorList.get(eid);
 		if(editor == null){
 			System.out.println("SessionManager.selectSession():editor = " + editor);
 			return;
@@ -568,7 +576,7 @@
 			sendCommand.setSID(sid);
 			channel.write(sendCommand);
 		}else {
-			sid = selectButtonEvent.getSID();
+			sid = event.getSID();
 			editor = new Editor(channel);
 			editor.setHost(myHost);
 			session = getSession(sid);