Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/handler/Editor.java @ 471:d2762d669617
sleep command to wait for singleton prevention
author | one |
---|---|
date | Tue, 12 Oct 2010 10:19:59 +0900 |
parents | e252d092b720 |
children | 596cc0a3beea 200166a494e9 |
comparison
equal
deleted
inserted
replaced
470:7f0d4e49eaf9 | 471:d2762d669617 |
---|---|
486 writeQueue.add(command); | 486 writeQueue.add(command); |
487 } | 487 } |
488 | 488 |
489 @Override | 489 @Override |
490 public void handle(REPCommand command, REPSelectionKey<REPCommand> key) throws IOException { | 490 public void handle(REPCommand command, REPSelectionKey<REPCommand> key) throws IOException { |
491 //ServerMainLoop.logger.writeLog("Manager "+manager.getId()+" read : command = " + command | |
492 // +" from "+manager.editorList.editorByChannel(channel)); | |
493 if (command.cmd==REP.SMCMD_JOIN||command.cmd==REP.SMCMD_PUT) { | 491 if (command.cmd==REP.SMCMD_JOIN||command.cmd==REP.SMCMD_PUT) { |
494 // assert false; | 492 // assert false; |
495 // 一つのエディタ上に複数のセッションが作られた場合。 | 493 // 一つのエディタ上に複数のセッションが作られた場合。 |
496 // 若干問題があるらしい | 494 // 若干問題があるらしい |
497 next = new Forwarder(manager,next.channel); | 495 next = new Forwarder(manager,next.channel); |
499 first.handle(command, key); | 497 first.handle(command, key); |
500 key.attach(new Dispatcher(manager,channel)); | 498 key.attach(new Dispatcher(manager,channel)); |
501 return; | 499 return; |
502 } | 500 } |
503 if (manager.sessionManage(this, command)) return; | 501 if (manager.sessionManage(this, command)) return; |
502 // ServerMainLoop.logger.writeLog("Editor"+eid+": handle command="+command); | |
504 manage(command); | 503 manage(command); |
505 } | 504 } |
506 | 505 |
507 @Override | 506 @Override |
508 public void cancel(REPSocketChannel<REPCommand> socketChannel) { | 507 public void cancel(REPSocketChannel<REPCommand> socketChannel) { |
642 * @param cmd the command to be translated. | 641 * @param cmd the command to be translated. |
643 * @return translated command. | 642 * @return translated command. |
644 */ | 643 */ |
645 public void transReceiveCmd(REPNode nextEditor,REPCommand cmd){ | 644 public void transReceiveCmd(REPNode nextEditor,REPCommand cmd){ |
646 assert (cmd.eid != eid); | 645 assert (cmd.eid != eid); |
647 unMergedCmds.addFirst(cmd); | 646 unMergedCmds.addFirst(new REPCommand(cmd)); |
648 } | 647 } |
649 | 648 |
650 public void setEid(int _eid){ | 649 public void setEid(int _eid){ |
651 eid = _eid; | 650 eid = _eid; |
652 } | 651 } |
653 | 652 |
654 public boolean checkMergeConflict(REPCommand command) { | 653 public boolean checkMergeConflict(REPCommand command) { |
655 unMergedCmds.addFirst(command); | 654 unMergedCmds.addFirst(new REPCommand(command)); |
656 | 655 |
657 REPCommand prev = sentMergedList.getFirst(); | 656 REPCommand prev = sentMergedList.getFirst(); |
658 if (prev.seq==command.seq) { | 657 if (prev.seq==command.seq) { |
659 // logger.writeLog("Input eid="+eid+"SentMergedList = "+sentMergedList); | 658 // logger.writeLog("Input eid="+eid+"SentMergedList = "+sentMergedList); |
660 sentMergedList.removeFirst(); | 659 sentMergedList.removeFirst(); |