changeset 160:6a5974dd0368

*** empty log message ***
author pin
date Thu, 28 Aug 2008 16:53:12 +0900
parents ecab03b50e08
children 5b4be02e7243
files rep/SessionManager.java
diffstat 1 files changed, 26 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/rep/SessionManager.java	Thu Aug 28 16:38:35 2008 +0900
+++ b/rep/SessionManager.java	Thu Aug 28 16:53:12 2008 +0900
@@ -45,18 +45,19 @@
 public class SessionManager implements ConnectionListener, REPActionListener{
 	
 	
-	private SessionList sessionlist;
+	//private SessionList sessionlist;
 	private List<Session> sessionList;
 	private SessionManagerGUI gui;
 	private Selector selector;
 	private SessionManagerList smList;
 	private String myHost;
 	private boolean isMaster = true;
-	private EditorList  ownEditorList;
+	//private EditorList  ownEditorList;
 	private List<Editor> editorList;
 	private String maxHost;
 	private boolean isSimulation;
 	private List<PacketSet> packetSetList;
+	private List<SessionManagerNode> managerList;
 	private static int temp_port;
 	private static int send_port;
 	
@@ -217,28 +218,32 @@
 			break;
 
 		case REP.SMCMD_SELECT_ACK:
-
+		{
 			String hostport = receivedCommand.string;
-			Editor editor2 = ownEditorList.getEditor(hostport);
-			if(editor2 != null) {
-				REPCommand command2 = new REPCommand();
-				command2.setCMD(REP.SMCMD_JOIN_ACK);
-				command2.setSID(receivedCommand.sid);
-				command2.setEID(receivedCommand.eid);
-				editor2.send(command2);
+			Editor editor = getEditor(hostport);
+			
+			if(editor != null) {
+				//host, port を見て、このコマンドが自分が送信したSelectコマンドのAckかどうかを判断する
+				REPCommand command = new REPCommand();
+				command.setCMD(REP.SMCMD_JOIN_ACK);
+				command.setSID(receivedCommand.sid);
+				command.setEID(receivedCommand.eid);
+				editor.send(command);
+				
 			}else{
+				//自分が送信したコマンドでなければ、次のSessionManagerへ中継する
 				smList.sendExcept(channel, receivedCommand);
 			}
+		}
 
 			break;
 
 		case REP.SMCMD_SM_JOIN:
-			
-			if(isSimulation){
-				smList.add(channel);
-				break;
-			}
-
+		{
+			managerList.add(channel);
+		}
+		
+		{
 			//SessionManagerのリストへ追加
 			smList.add(channel);
 
@@ -274,10 +279,7 @@
 			sendCommand.setString(receivedCommand.string);
 			smList.sendExcept(channel, sendCommand);
 
-			if(isMaster){
-			}else {
-			}
-
+		}
 			break;
 
 		case REP.SMCMD_SM_JOIN_ACK:
@@ -354,6 +356,10 @@
 		}
 	}
 
+	private Editor getEditor(String hostport) {
+		return null;
+	}
+
 	private Editor getEditor(REPSocketChannel<REPCommand> channel) {
 		// TODO Auto-generated method stub
 		for(Editor editor : editorList){