comparison 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
comparison
equal deleted inserted replaced
388:4ec3b70f8f09 389:4b535bef903a
168 editor.setSID(sid); // mark as selected 168 editor.setSID(sid); // mark as selected
169 selectSession0(sid, session, editor.getEID(), editor); 169 selectSession0(sid, session, editor.getEID(), editor);
170 } 170 }
171 171
172 private void selectSession0(int sid, Session session, int eid, REPNode editor) { 172 private void selectSession0(int sid, Session session, int eid, REPNode editor) {
173 logger.writeLog("Select sid="+sid+" and "+editor);
173 if (editor.isDirect()&&editor.getEID()==eid) { 174 if (editor.isDirect()&&editor.getEID()==eid) {
174 REPCommand command = new REPCommand(); 175 REPCommand command = new REPCommand();
175 command.setSID(sid); 176 command.setSID(sid);
176 command.setEID(eid); 177 command.setEID(eid);
177 command.setString(session.getName()); 178 command.setString(session.getName());
178 editor.selectSession(command, session); 179 if(session.hasOwner()){
180 editor.selectSession(command,session);
181 }else {
182 forwardSelect(sid, session, eid, editor);
183 }
179 } else { 184 } else {
180 // we don't have this editor, search the editor first. 185 // we don't have this editor, search the editor first.
181 REPNode next = routingTable.toSessionManager(getSMID(eid)); 186 REPNode next = routingTable.toSessionManager(getSMID(eid));
182 // pass the select command to the next path. 187 // pass the select command to the next path.
183 REPCommand command = new REPCommand(); 188 REPCommand command = new REPCommand();
384 } 389 }
385 // Do not directly addForwarder(forwarder). It may be 390 // Do not directly addForwarder(forwarder). It may be
386 // shared among sessions. 391 // shared among sessions.
387 REPNode f = createSessionForwarder(command.sid, forwarder); 392 REPNode f = createSessionForwarder(command.sid, forwarder);
388 session.addForwarder(f); // f.next is set up here. 393 session.addForwarder(f); // f.next is set up here.
389 forwarder.selectSession(command,session); 394 if(session.hasOwner()){
395 forwarder.selectSession(command,session);
396 }else {
397 forwardSelect(command.sid, session, command.eid, forwarder);
398 }
390 } 399 }
391 break; 400 break;
392 case SMCMD_SELECT_ACK: 401 case SMCMD_SELECT_ACK:
393 { 402 {
394 // Sessionが見つかったので、select したeditorに教える。 403 // Sessionが見つかったので、select したeditorに教える。
482 */ 491 */
483 private void searchSelectedEditor(REPCommand command, REPNode editor) { 492 private void searchSelectedEditor(REPCommand command, REPNode editor) {
484 for(;editor.isDirect();editor = editor.getNextForwarder()) { 493 for(;editor.isDirect();editor = editor.getNextForwarder()) {
485 if (editor.getEID()==command.eid) { 494 if (editor.getEID()==command.eid) {
486 // select したeditor を見つけた 495 // select したeditor を見つけた
487 command.cmd=REP.SMCMD_JOIN_ACK; 496 editor.joinAck(command,command.sid);
488 editor.send(command);
489 sendUpdate(command.sid);
490 if (sync) {
491 REPCommand sync = new REPCommand(command);
492 sync.setCMD(REP.SMCMD_SYNC);
493 editor.sendSync(sync);
494 }
495 return; 497 return;
496 } 498 }
497 } 499 }
498 // ここにはありませんでした。 500 // ここにはありませんでした。
499 editor.send(command); 501 editor.send(command);
598 } 600 }
599 601
600 public void addWaitingSessionManager(REPNode fw, REPCommand command) { 602 public void addWaitingSessionManager(REPNode fw, REPCommand command) {
601 smList.addWaitingSessionManager(fw, command); 603 smList.addWaitingSessionManager(fw, command);
602 } 604 }
605
603 } 606 }