diff rep/SessionManager.java @ 389:4b535bef903a

23
author one@firefly.cr.ie.u-ryukyu.ac.jp
date Mon, 10 Nov 2008 22:24:21 +0900
parents 6f356d160e58
children 3b0a5a55e3ee
line wrap: on
line diff
--- a/rep/SessionManager.java	Mon Nov 10 22:23:02 2008 +0900
+++ b/rep/SessionManager.java	Mon Nov 10 22:24:21 2008 +0900
@@ -170,12 +170,17 @@
 	}
 
 	private void selectSession0(int sid, Session session, int eid, REPNode editor) {
+		logger.writeLog("Select sid="+sid+" and "+editor);
 		if (editor.isDirect()&&editor.getEID()==eid) {
 			REPCommand command = new REPCommand();
 			command.setSID(sid);
 			command.setEID(eid);
 			command.setString(session.getName());
-			editor.selectSession(command, session);
+			if(session.hasOwner()){
+				editor.selectSession(command,session);
+			}else {
+				forwardSelect(sid, session, eid, editor);
+			}
 		} else {
 			// we don't have this editor, search the editor first.
 			REPNode next = routingTable.toSessionManager(getSMID(eid));
@@ -386,7 +391,11 @@
 			// shared among sessions.
 			REPNode f = createSessionForwarder(command.sid, forwarder);
 			session.addForwarder(f); // f.next is set up here.
-			forwarder.selectSession(command,session);
+			if(session.hasOwner()){
+				forwarder.selectSession(command,session);
+			}else {
+				forwardSelect(command.sid, session, command.eid, forwarder);
+			}
 		}
 			break;
 		case SMCMD_SELECT_ACK:
@@ -484,14 +493,7 @@
 		for(;editor.isDirect();editor = editor.getNextForwarder()) {
 			if (editor.getEID()==command.eid) {
 				// select したeditor を見つけた
-				command.cmd=REP.SMCMD_JOIN_ACK;
-				editor.send(command);
-				sendUpdate(command.sid);
-				if (sync) {
-					REPCommand sync = new REPCommand(command);
-					sync.setCMD(REP.SMCMD_SYNC);
-					editor.sendSync(sync);
-				}
+				editor.joinAck(command,command.sid);
 				return;
 			}
 		}
@@ -600,4 +602,5 @@
 	public void addWaitingSessionManager(REPNode fw, REPCommand command) {
 		smList.addWaitingSessionManager(fw, command);
 	}
+
 }