Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/Session.java @ 315:20fb70068089
*** empty log message ***
author | kono |
---|---|
date | Mon, 06 Oct 2008 18:58:49 +0900 |
parents | 8f6b7a1890b2 |
children | 77f443f6dc9f |
comparison
equal
deleted
inserted
replaced
314:edb373aa421e | 315:20fb70068089 |
---|---|
1 package rep; | 1 package rep; |
2 | 2 |
3 import java.util.Iterator; | 3 import java.util.Iterator; |
4 import java.util.LinkedList; | 4 import java.util.LinkedList; |
5 import java.util.List; | |
6 import rep.channel.REPSocketChannel; | 5 import rep.channel.REPSocketChannel; |
7 | 6 |
8 public class Session { | 7 public class Session { |
9 private Editor masterEditor; | 8 private Editor masterEditor; |
10 private int sessionID; | 9 private int sessionID; |
85 for(Editor editor : editorList){ | 84 for(Editor editor : editorList){ |
86 if(editor.getChannel() == channel) return editor; | 85 if(editor.getChannel() == channel) return editor; |
87 } | 86 } |
88 return null; | 87 return null; |
89 } | 88 } |
90 public void translate(REPSocketChannel<REPCommand> channel, REPCommand command) { | 89 |
91 Editor editor = getEditor(channel); | 90 |
92 List<REPCommand> commandList = editor.translate(command); | 91 Editor getNextEditor(Editor editor) { |
93 Editor nextEditor = getNextEditor(editor); | |
94 | |
95 for(REPCommand cmd: commandList){ | |
96 nextEditor.send(cmd); | |
97 } | |
98 } | |
99 private Editor getNextEditor(Editor editor) { | |
100 int eid = editor.getEID(); | 92 int eid = editor.getEID(); |
101 int neid = (eid+1)%editorList.size(); | 93 int neid = (eid+1)%editorList.size(); |
102 Editor nextEditor = editorList.get(neid); | 94 Editor nextEditor = editorList.get(neid); |
103 return nextEditor; | 95 return nextEditor; |
104 } | 96 } |