Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/handler/Editor.java @ 401:2cf5392b2a9f
add INSERT_USER, DELETE_USER
JOIN_ACK fix
author | one |
---|---|
date | Tue, 25 Nov 2008 03:07:05 +0900 |
parents | 29f01a7ce71f |
children | 4bb04d5a9bbf |
comparison
equal
deleted
inserted
replaced
400:29f01a7ce71f | 401:2cf5392b2a9f |
---|---|
57 return; | 57 return; |
58 case REPCMD_DELETE_USER: | 58 case REPCMD_DELETE_USER: |
59 command.cmd = REP.REPCMD_INSERT; | 59 command.cmd = REP.REPCMD_INSERT; |
60 userEditorCommand(command); | 60 userEditorCommand(command); |
61 return; | 61 return; |
62 } | 62 case REPCMD_INSERT: |
63 if (command.eid == REP.MERGE_EID.id){ | 63 case REPCMD_DELETE: |
64 //マージコマンドが返ってきた | 64 if (command.eid == REP.MERGE_EID.id){ |
65 checkDouble(sentList); | 65 //マージコマンドが返ってきた |
66 if(translator.checkMergeConflict(command)){ | 66 checkDouble(sentList); |
67 //マージ中にエディタからの割り込みがあった場合 | 67 if(translator.checkMergeConflict(command)){ |
68 translator.getMergeAgain(this); | 68 //マージ中にエディタからの割り込みがあった場合 |
69 } | 69 translator.getMergeAgain(this); |
70 checkEndMerge(); | 70 } |
71 checkDouble(sentList); | 71 checkEndMerge(); |
72 return; | 72 checkDouble(sentList); |
73 } else if (command.eid == next.getEID()){ | |
74 // 次のEditorで一周するコマンドが来た | |
75 if (next==this) return; // singleton case | |
76 // これは、distributed case では、うまくいかないので、送り先のforwarder で処理する。 | |
77 if (next.isDirect()&&command.cmd==REP.SMCMD_QUIT_2) { | |
78 next.forwardedCommandManage(command); | |
79 return; | 73 return; |
80 } | 74 } else if (command.eid == eid){ |
81 } else if (command.eid == eid){ | 75 // 編集コマンドが一周して来た |
82 // 編集コマンドが一周して来た | 76 if (waitingRequired(command)) return; |
77 checkReturnedCommand(command); | |
78 checkDouble(sentList); | |
79 return; | |
80 } | |
81 | |
82 //他のエディタからの編集コマンド | |
83 if (waitingRequired(command)) return; | 83 if (waitingRequired(command)) return; |
84 checkReturnedCommand(command); | 84 translator.transReceiveCmd(next,command); |
85 checkDouble(sentList); | 85 if(command.cmd==REP.REPCMD_DELETE) { |
86 return; | 86 // delete のundo用の文字列は、外に出す意味はない |
87 } | 87 command.string=null; |
88 | 88 } |
89 //他のエディタからの編集コマンド | 89 sendEditorCommand(command); |
90 if (waitingRequired(command)) return; | 90 return; |
91 translator.transReceiveCmd(next,command); | 91 default: |
92 if(command.cmd==REP.REPCMD_DELETE) { | 92 assert(false); |
93 // delete のundo用の文字列は、外に出す意味はない | 93 } |
94 command.string=null; | |
95 } | |
96 sendEditorCommand(command); | |
97 return; | |
98 } | 94 } |
99 | 95 |
100 private void userEditorCommand(REPCommand command) { | 96 private void userEditorCommand(REPCommand command) { |
101 //エディタからの新たな編集コマンド | 97 //エディタからの新たな編集コマンド |
102 if (next==this) return; // singleton case | 98 if (next==this) return; // singleton case |
287 case REPCMD_INSERT: | 283 case REPCMD_INSERT: |
288 case REPCMD_DELETE_USER: | 284 case REPCMD_DELETE_USER: |
289 case REPCMD_INSERT_USER: | 285 case REPCMD_INSERT_USER: |
290 case REPCMD_DELETE_ACK: | 286 case REPCMD_DELETE_ACK: |
291 case REPCMD_INSERT_ACK: | 287 case REPCMD_INSERT_ACK: |
292 case REPCMD_NOP: | |
293 { | 288 { |
294 translate(command); | 289 translate(command); |
295 break; | 290 break; |
296 } | 291 } |
297 | 292 |
347 } | 342 } |
348 | 343 |
349 | 344 |
350 @Override | 345 @Override |
351 public void handle(REPCommand command, REPSelectionKey<REPCommand> key) throws IOException { | 346 public void handle(REPCommand command, REPSelectionKey<REPCommand> key) throws IOException { |
352 ServerMainLoop.logger.writeLog("Manager "+manager.getId()+"read : command = " + command | 347 ServerMainLoop.logger.writeLog("Manager "+manager.getId()+" read : command = " + command |
353 +" from "+manager.editorList.editorByChannel(channel)); | 348 +" from "+manager.editorList.editorByChannel(channel)); |
354 if (command.cmd==REP.SMCMD_JOIN||command.cmd==REP.SMCMD_PUT) { | 349 if (command.cmd==REP.SMCMD_JOIN||command.cmd==REP.SMCMD_PUT) { |
355 assert false; | 350 assert false; |
356 // 若干問題があるらしい | 351 // 若干問題があるらしい |
357 next = new Forwarder(manager,next.channel); | 352 next = new Forwarder(manager,next.channel); |
384 if (command.cmd==REP.SMCMD_QUIT_2) { | 379 if (command.cmd==REP.SMCMD_QUIT_2) { |
385 // we have to wait next editor's finishing before sending this. | 380 // we have to wait next editor's finishing before sending this. |
386 // this is odd, but the editor itself does not know it's merging | 381 // this is odd, but the editor itself does not know it's merging |
387 // state. Only this session manager knows it. | 382 // state. Only this session manager knows it. |
388 setQuit2(command); | 383 setQuit2(command); |
384 return; | |
389 } | 385 } |
390 send(command); | 386 send(command); |
391 } | 387 } |
392 | 388 |
393 /** | 389 /** |