Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/handler/Editor.java @ 385:1fca50ce3508
first-working-version
author | one@firefly.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 10 Nov 2008 22:18:14 +0900 |
parents | bcdf5476b8e4 |
children | bba62c4ac323 |
comparison
equal
deleted
inserted
replaced
384:bcdf5476b8e4 | 385:1fca50ce3508 |
---|---|
19 private List<REPCommand> sentList = new LinkedList<REPCommand>(); | 19 private List<REPCommand> sentList = new LinkedList<REPCommand>(); |
20 // REPCommands we are going to send to the next editor | 20 // REPCommands we are going to send to the next editor |
21 //private REPCommand quit2 = null; | 21 //private REPCommand quit2 = null; |
22 private SessionManager manager; | 22 private SessionManager manager; |
23 private REPCommand quit2=null; | 23 private REPCommand quit2=null; |
24 | 24 static final boolean doOptimize = true; |
25 public Editor(SessionManager manager,boolean doOptimize,int editorNo){ | 25 |
26 public Editor(SessionManager manager,int editorNo){ | |
26 super(manager); | 27 super(manager); |
27 this.manager = manager; | 28 this.manager = manager; |
28 eid = editorNo; | 29 eid = editorNo; |
29 REPCommandOptimizer optimizer; | 30 REPCommandOptimizer optimizer; |
30 if (doOptimize) optimizer = new DeleteInsertOptimizer(); //タカノがつくったおぷてぃまいざ | 31 if (doOptimize) optimizer = new DeleteInsertOptimizer(); //タカノがつくったおぷてぃまいざ |
32 translator = new Translator(eid,optimizer); | 33 translator = new Translator(eid,optimizer); |
33 | 34 |
34 } | 35 } |
35 | 36 |
36 public Editor(SessionManager manager,int editorNo, REPSocketChannel<REPCommand> channel){ | 37 public Editor(SessionManager manager,int editorNo, REPSocketChannel<REPCommand> channel){ |
37 this(manager,false,editorNo); | 38 this(manager,editorNo); |
38 this.channel = channel; | 39 this.channel = channel; |
39 } | 40 } |
40 | 41 |
41 public void translate(REPCommand command){ | 42 public void translate(REPCommand command){ |
42 | 43 |
224 | 225 |
225 /* Handle special case first, usually these cases | 226 /* Handle special case first, usually these cases |
226 * are handled in the next Editor in a session manager, but | 227 * are handled in the next Editor in a session manager, but |
227 * it is forwarded here. | 228 * it is forwarded here. |
228 */ | 229 */ |
229 public void forwardedCommandManage(REPCommand command, REPNode forwarder) { | 230 public void forwardedCommandManage(REPCommand command) { |
230 if (command.cmd==REP.SMCMD_QUIT_2) { | 231 if (command.cmd==REP.SMCMD_QUIT_2) { |
231 // we have to wait next editor's finishing before sending this. | 232 // we have to wait next editor's finishing before sending this. |
232 // this is odd, but the editor itself does not know it's merging | 233 // this is odd, but the editor itself does not know it's merging |
233 // state. Only this session manager knows it. | 234 // state. Only this session manager knows it. |
234 setQuit2(command); | 235 setQuit2(command); |
241 case REPCMD_NOP: | 242 case REPCMD_NOP: |
242 checkReturnedCommand(command); | 243 checkReturnedCommand(command); |
243 return; | 244 return; |
244 } | 245 } |
245 } | 246 } |
246 manage(command); | 247 send(command); |
248 } | |
249 | |
250 @Override | |
251 public void send(REPCommand command) { | |
252 assert(command!=null); | |
253 assert(channel!=null); | |
254 REPCommand c = new REPCommand(command); | |
255 manager.addWriteQueue(new PacketSet(channel,null, c)); | |
247 } | 256 } |
248 } | 257 } |