# HG changeset patch # User kono # Date 1224617272 -32400 # Node ID c78569ab5fce07d8618f6a6b0ffb957670629891 # Parent 85a5980d96d8d7d15c185810f1ea744290f1da13 *** empty log message *** diff -r 85a5980d96d8 -r c78569ab5fce rep/ConnectButtonEvent.java --- a/rep/ConnectButtonEvent.java Wed Oct 22 04:07:24 2008 +0900 +++ b/rep/ConnectButtonEvent.java Wed Oct 22 04:27:52 2008 +0900 @@ -13,7 +13,7 @@ } public void exec(SessionManager manager) { - manager.connectSession(host); + manager.connectSessionManager(host); } } diff -r 85a5980d96d8 -r c78569ab5fce rep/Editor.java --- a/rep/Editor.java Wed Oct 22 04:07:24 2008 +0900 +++ b/rep/Editor.java Wed Oct 22 04:27:52 2008 +0900 @@ -219,4 +219,28 @@ public boolean isMaster() { return mode==REP.SMCMD_PUT; } + + /* Handle special case first, usually these cases + * are handled in the next Editor in a session manager, but + * it is forwarded here. + */ + public void forwardedCommandManage(REPCommand command, Forwarder forwarder) { + if (command.cmd==REP.SMCMD_QUIT_2) { + // we have to wait next editor's finishing before sending this. + // this is odd, but the editor itself does not know it's merging + // state. Only this session manager knows it. + setQuit2(command); + } else if (command.eid==eid) { + // if we handle in editor.manage(), this editor cannot distinguish this + // and user input command from the editor. + switch(command.cmd) { + case REPCMD_DELETE: + case REPCMD_INSERT: + case REPCMD_NOP: + checkReturnedCommand(command); + return; + } + } + manage(command); + } } diff -r 85a5980d96d8 -r c78569ab5fce rep/Forwarder.java --- a/rep/Forwarder.java Wed Oct 22 04:07:24 2008 +0900 +++ b/rep/Forwarder.java Wed Oct 22 04:27:52 2008 +0900 @@ -86,29 +86,18 @@ REPCommand command) throws IOException { Session s = manager.getSession(command.sid); if (s==null) throw new IOException(); - Forwarder editor = s.getForwarder(channel); - if (editor==null) throw new IOException(); - if (!editor.isDirect()) { - editor.send(command); + Forwarder f = s.getForwarder(channel); + if (f==null) throw new IOException(); + if (!f.isDirect()) { + // another forwarder, pass it to the next session manager + f.send(command); return; } /* - * local editor case. Handle special case first, usually these cases - * are handled in the next Editor in a session manager, but - * it is forwarded here. + * local editor case. */ - if (command.cmd==REP.SMCMD_QUIT_2) { - // we have to wait next editor's finishing before sending this. - // this is odd, but the editor itself does not know it's merging - // state. Only this session manager knows it. - editor.setQuit2(command); - } else if (command.eid==editor.eid) { - // if we handle in editor.manage(), this editor cannot distinguish this - // and user input command from the editor. - ((Editor)editor).checkReturnedCommand(command); - } else { - editor.manage(command); - } + Editor editor = (Editor)f; + editor.forwardedCommandManage(command, this); } public void setMode(REP cmd) { diff -r 85a5980d96d8 -r c78569ab5fce rep/SessionManager.java --- a/rep/SessionManager.java Wed Oct 22 04:07:24 2008 +0900 +++ b/rep/SessionManager.java Wed Oct 22 04:27:52 2008 +0900 @@ -331,7 +331,7 @@ * ならない。複数のSession Managerにjoinすることは出来ない。(NATを実装するまでは)。 * @param host */ - public void connectSession(String host, int port) { + public void connectSessionManager(String host, int port) { if (sm_join_channel!=null) return; if (!sessionList.isEmpty()) return; if (!smList.isMaster()) return; @@ -351,8 +351,8 @@ } } - public void connectSession(String host) { - connectSession(host,parent_port); + public void connectSessionManager(String host) { + connectSessionManager(host,parent_port); } /** diff -r 85a5980d96d8 -r c78569ab5fce test/sematest/TestInterManagerSession.java --- a/test/sematest/TestInterManagerSession.java Wed Oct 22 04:07:24 2008 +0900 +++ b/test/sematest/TestInterManagerSession.java Wed Oct 22 04:27:52 2008 +0900 @@ -40,17 +40,17 @@ }, new SessionManagerEvent() { public void exec(SessionManager manager) { - manager.connectSession(host); + manager.connectSessionManager(host); } }, new SessionManagerEvent() { public void exec(SessionManager manager) { // try to make a loop if (false) { - sessionManagers[0].connectSession(host, + sessionManagers[0].connectSessionManager(host, manager.getPort()); } - manager.connectSession(host); + manager.connectSessionManager(host); manager.execAfterConnect( new SessionManagerEvent() { public void exec(SessionManager manager) {