0
|
1 package rep;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.net.InetSocketAddress;
|
2
|
5 import java.nio.channels.SelectableChannel;
|
0
|
6 import java.nio.channels.SelectionKey;
|
|
7 import java.nio.channels.Selector;
|
179
|
8
|
178
|
9 import java.util.Iterator;
|
83
|
10 import java.util.LinkedList;
|
144
|
11 import java.util.List;
|
178
|
12 import java.util.concurrent.BlockingQueue;
|
192
|
13 import java.util.concurrent.LinkedBlockingQueue;
|
0
|
14
|
198
|
15 import javax.swing.SwingUtilities;
|
|
16
|
123
|
17 import rep.channel.REPServerSocketChannel;
|
133
|
18 import rep.channel.REPSocketChannel;
|
144
|
19 import rep.handler.PacketSet;
|
146
|
20 import rep.handler.REPHandler;
|
148
|
21 import rep.handler.REPHandlerImpl;
|
164
|
22 import rep.handler.REPHandlerInMerge;
|
158
|
23 import rep.channel.REPSelector;
|
56
|
24 import rep.xml.SessionXMLDecoder;
|
45
|
25 import rep.xml.SessionXMLEncoder;
|
198
|
26 import rep.channel.REPSelectionKey;
|
|
27 /*
|
1
|
28 //+-------+--------+--------+-------+--------+---------+------+
|
|
29 //| cmd | session| editor | seqid | lineno | textsiz | text |
|
|
30 //| | id | id | | | | |
|
|
31 //+-------+--------+--------+-------+--------+---------+------+
|
|
32 //o-------header section (network order)-------------o
|
198
|
33 int cmd; // command
|
101
|
34 int sid; // session ID : uniqu to editing file
|
123
|
35 int eid; // editor ID : owner editor ID = 1。Session に対して unique
|
122
|
36 int seqno; // Sequence number : sequence number はエディタごとに管理
|
1
|
37 int lineno; // line number
|
101
|
38 int textsize; // textsize : bytesize
|
198
|
39 byte[] text;
|
|
40 */
|
1
|
41
|
8
|
42 public class SessionManager implements ConnectionListener, REPActionListener{
|
0
|
43
|
164
|
44 private LinkedList<Session> sessionList;
|
83
|
45 private SessionManagerGUI gui;
|
198
|
46 private REPSelector<REPCommand> selector;
|
7
|
47 private SessionManagerList smList;
|
17
|
48 private String myHost;
|
21
|
49 private boolean isMaster = true;
|
144
|
50 private List<Editor> editorList;
|
78
|
51 private String maxHost;
|
148
|
52 private boolean isSimulation;
|
155
|
53 private List<PacketSet> packetSetList;
|
178
|
54 private BlockingQueue<SessionManagerEvent> waitingQueue;
|
95
|
55 private static int temp_port;
|
|
56 private static int send_port;
|
101
|
57 static final int DEFAULT_PORT = 8766;
|
|
58
|
2
|
59 public SessionManager(int port) {
|
191
|
60
|
2
|
61 }
|
|
62
|
|
63 public void openSelector() throws IOException{
|
191
|
64 selector = REPSelector.create();
|
2
|
65 }
|
0
|
66
|
155
|
67 public void init(int port) throws InterruptedException, IOException {
|
2
|
68
|
186
|
69 REPServerSocketChannel<REPCommand> ssc = REPServerSocketChannel.<REPCommand>open(new REPCommandPacker());
|
122
|
70 ssc.configureBlocking(false); //reuse address 必須
|
101
|
71 ssc.socket().setReuseAddress(true);
|
192
|
72 ssc.socket().bind(new InetSocketAddress("localhost", port));
|
|
73 ssc.register(selector, SelectionKey.OP_ACCEPT, new REPHandlerImpl(-1, this));
|
|
74 //registerChannel(selector, ssc, SelectionKey.OP_ACCEPT);
|
6
|
75
|
|
76
|
163
|
77 //sessionlist = new SessionList();
|
144
|
78 sessionList = new LinkedList<Session>();
|
7
|
79 smList = new SessionManagerList();
|
162
|
80 //ownEditorList = new EditorList();
|
144
|
81 editorList = new LinkedList<Editor>();
|
155
|
82 packetSetList = new LinkedList<PacketSet>();
|
0
|
83
|
192
|
84 waitingQueue = new LinkedBlockingQueue<SessionManagerEvent>();
|
155
|
85 // main loop
|
191
|
86 //mainLoop();
|
155
|
87 }
|
|
88
|
|
89 private void mainLoop() throws IOException {
|
0
|
90 while(true){
|
178
|
91 if(checkSend()){
|
|
92 if(selector.selectNow() > 0){
|
|
93 select();
|
|
94 }
|
|
95 continue;
|
|
96 }
|
0
|
97 selector.select();
|
144
|
98 select();
|
|
99 }
|
|
100 }
|
|
101
|
178
|
102 private boolean checkSend() {
|
|
103 for(Iterator<PacketSet> it = packetSetList.iterator(); it.hasNext();){
|
|
104 PacketSet p = it.next();
|
|
105 if(p.getEditor().isMerging()) {
|
|
106 continue;
|
|
107 }else{
|
|
108 manage(p.channel, p.command);
|
|
109 it.remove();
|
|
110 }
|
|
111 }
|
|
112 return false;
|
|
113 }
|
|
114
|
144
|
115 private void select() throws IOException {
|
178
|
116 SessionManagerEvent e = waitingQueue.poll();
|
|
117 if(e != null) {
|
|
118 e.exec();
|
|
119 }
|
198
|
120 for(REPSelectionKey<REPCommand> key : selector.selectedKeys1()){
|
144
|
121 if(key.isAcceptable()){
|
|
122 /*** serverChannelはenableになったSelectionKeyのchannel ***/
|
199
|
123 // REPServerSocketChannel serverChannel = (REPServerSocketChannel)key.channel();
|
|
124 REPSocketChannel<REPCommand> channel = key.accept(new REPCommandPacker());
|
|
125 //REPSocketChannel channel = serverChannel.accept1(); //keyからchannelを取って、accept
|
144
|
126 registerChannel (selector, channel, SelectionKey.OP_READ);
|
|
127 channel = null;
|
123
|
128
|
144
|
129 }else if(key.isReadable()){
|
|
130
|
199
|
131 //REPHandler handler = (REPHandler)key.attachment();
|
|
132
|
|
133 //いんちき
|
|
134 REPHandler handler = new REPHandlerImpl(-1, this);
|
146
|
135 handler.handle(key);
|
144
|
136
|
|
137 }else if(key.isConnectable()){
|
|
138 System.out.println("Connectable");
|
0
|
139 }
|
|
140 }
|
|
141 }
|
1
|
142
|
178
|
143 private void registerChannel(Selector selector, SelectableChannel channel, int ops) throws IOException {
|
2
|
144 if(channel == null) {
|
|
145 return;
|
|
146 }
|
|
147 channel.configureBlocking(false);
|
170
|
148 REPHandler handler = new REPHandlerImpl(-1, this);
|
148
|
149 channel.register(selector, ops, handler);
|
2
|
150 }
|
|
151
|
144
|
152 public void manage(REPSocketChannel<REPCommand> channel, REPCommand receivedCommand) {
|
75
|
153 if(receivedCommand == null) return;
|
158
|
154 //Session session;
|
141
|
155 REPCommand sendCommand = new REPCommand(receivedCommand);
|
178
|
156 REPSocketChannel<REPCommand> send = channel;
|
144
|
157
|
75
|
158 switch(receivedCommand.cmd){
|
144
|
159
|
0
|
160 case REP.SMCMD_JOIN:
|
164
|
161 {
|
|
162 //どのSessionにも属さないエディタをリストに追加
|
|
163 Editor editor = new Editor(editorList.size(), channel);
|
|
164 editor.setHost(myHost);
|
|
165 editorList.add(editor);
|
144
|
166
|
198
|
167 //リストのコピーをGUIに渡す
|
|
168 LinkedList<Session> sList = new LinkedList<Session>(sessionList);
|
|
169 LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
|
164
|
170 //GUIに反映
|
198
|
171 Runnable doRun = new DoGUIUpdate(sList, eList, gui);
|
|
172 SwingUtilities.invokeLater(doRun);
|
199
|
173
|
164
|
174 }
|
|
175
|
|
176 break;
|
144
|
177
|
1
|
178 case REP.SMCMD_JOIN_ACK:
|
144
|
179
|
1
|
180 break;
|
144
|
181
|
0
|
182 case REP.SMCMD_PUT:
|
164
|
183 {
|
|
184 //エディタのリストに追加
|
|
185 Editor editor = new Editor(editorList.size(), channel);
|
|
186 editorList.add(editor);
|
|
187
|
|
188 //Sessionを生成
|
|
189 int sid = sessionList.size();
|
|
190 editor = new Editor(0, channel);
|
|
191 editor.setHost(myHost);
|
|
192 Session session = new Session(sid, editor);
|
|
193 session.hasOwner(true);
|
|
194 sessionList.add(new Session(sid, editor));
|
|
195
|
|
196 //GUIに反映
|
178
|
197 //gui.update();ぐらいで
|
164
|
198 gui.setComboSession(session.getSID(), session.getName());
|
|
199 gui.setComboEditor(editor.getEID(), editor.getChannel());
|
158
|
200
|
164
|
201 //エディタにAckを送信
|
|
202 sendCommand.setCMD(REP.SMCMD_PUT_ACK);
|
|
203 sendCommand.setEID(editor.getEID());
|
|
204 sendCommand.setSID(session.getSID());
|
|
205 editor.send(sendCommand);
|
144
|
206
|
164
|
207 //他のSessionManagerへSessionの追加を報告
|
|
208 SessionXMLEncoder sessionEncoder = new SessionXMLEncoder(session);
|
|
209 REPCommand command = new REPCommand();
|
|
210 command.setSID(session.getSID());
|
|
211 command.setString(sessionEncoder.sessionListToXML());
|
|
212 command.setCMD(REP.SMCMD_UPDATE);
|
|
213 smList.sendExcept(channel, command);
|
|
214
|
|
215 }
|
|
216
|
|
217 break;
|
133
|
218
|
0
|
219 case REP.SMCMD_SELECT:
|
164
|
220 {
|
178
|
221 //他のSessionManagerをエディタとしてSessionに追加
|
164
|
222 Editor editor = new Editor(channel);
|
|
223 Session session = getSession(receivedCommand.sid);
|
|
224 session.addEditor(editor);
|
|
225
|
|
226 if(session.hasOwner()){
|
|
227 //このSessionManagerがオーナーを持っている場合、Sessionにエディタを追加し、エディタへAckを返す
|
|
228 sendCommand.setCMD(REP.SMCMD_SELECT_ACK);
|
|
229 sendCommand.setEID(editor.getEID());
|
|
230 editor.send(sendCommand);
|
|
231 }else{
|
|
232 //オーナーを持ってない場合は、オーナーを持っているSessionManagerへSELECTコマンドを中継する
|
|
233 Editor owner = session.getOwner();
|
|
234 owner.send(receivedCommand);
|
148
|
235 }
|
164
|
236 }
|
144
|
237
|
164
|
238 break;
|
144
|
239
|
8
|
240 case REP.SMCMD_SELECT_ACK:
|
160
|
241 {
|
85
|
242 String hostport = receivedCommand.string;
|
160
|
243 Editor editor = getEditor(hostport);
|
164
|
244
|
160
|
245 if(editor != null) {
|
|
246 //host, port を見て、このコマンドが自分が送信したSelectコマンドのAckかどうかを判断する
|
|
247 REPCommand command = new REPCommand();
|
|
248 command.setCMD(REP.SMCMD_JOIN_ACK);
|
|
249 command.setSID(receivedCommand.sid);
|
|
250 command.setEID(receivedCommand.eid);
|
|
251 editor.send(command);
|
164
|
252
|
85
|
253 }else{
|
160
|
254 //自分が送信したコマンドでなければ、次のSessionManagerへ中継する
|
85
|
255 smList.sendExcept(channel, receivedCommand);
|
|
256 }
|
160
|
257 }
|
144
|
258
|
164
|
259 break;
|
144
|
260
|
8
|
261 case REP.SMCMD_SM_JOIN:
|
164
|
262
|
160
|
263 {
|
122
|
264 //SessionManagerのリストへ追加
|
83
|
265 smList.add(channel);
|
144
|
266
|
122
|
267 //XMLからSessionListオブジェクトを生成する。
|
77
|
268 SessionXMLDecoder decoder = new SessionXMLDecoder();
|
79
|
269 SessionList receivedSessionList = decoder.decode(receivedCommand.string);
|
144
|
270
|
122
|
271 //SessionListへ追加し変換テーブルを生成する。
|
163
|
272 //sessionlist.update(channel, receivedSessionList);
|
144
|
273
|
122
|
274 //myHost を設定。
|
178
|
275 //立ち上げ時にやるとlocalhostしか取れない
|
76
|
276 if(myHost == null) setMyHostName(getLocalHostName(channel));
|
144
|
277
|
122
|
278 //maxHost を設定。
|
95
|
279 if(setMaxHost(channel, receivedSessionList.getMaxHost())){
|
|
280 sendCommand = new REPCommand();
|
|
281 sendCommand.setCMD(REP.SMCMD_CH_MASTER);
|
|
282 sendCommand.setString(maxHost);
|
|
283 smList.sendExcept(channel, sendCommand);
|
|
284 }
|
144
|
285
|
122
|
286 //SessionListからXMLを生成。
|
|
287 //joinしてきたSessionManagerに対してACKを送信。
|
164
|
288 SessionXMLEncoder sessionlistEncoder = new SessionXMLEncoder(sessionList);
|
78
|
289 sendCommand = new REPCommand();
|
|
290 sendCommand.setCMD(REP.SMCMD_SM_JOIN_ACK);
|
|
291 sendCommand.setString(sessionlistEncoder.sessionListToXML());
|
178
|
292 send.write(sendCommand);
|
144
|
293
|
122
|
294 //その他の SessionManager に対して SMCMD_UPDATEを 送信。
|
78
|
295 sendCommand = new REPCommand();
|
83
|
296 sendCommand.setCMD(REP.SMCMD_UPDATE);
|
78
|
297 sendCommand.setString(receivedCommand.string);
|
|
298 smList.sendExcept(channel, sendCommand);
|
144
|
299
|
160
|
300 }
|
164
|
301 break;
|
144
|
302
|
8
|
303 case REP.SMCMD_SM_JOIN_ACK:
|
144
|
304
|
122
|
305 //XMLからSessionListオブジェクトを生成。
|
82
|
306 SessionXMLDecoder decoder2 = new SessionXMLDecoder();
|
|
307 SessionList receivedSessionList2 = decoder2.decode(receivedCommand.string);
|
144
|
308
|
122
|
309 //maxHostを決定。
|
95
|
310 if(setMaxHost(channel, receivedSessionList2.getMaxHost())){
|
|
311 sendCommand = new REPCommand();
|
|
312 sendCommand.setCMD(REP.SMCMD_CH_MASTER);
|
|
313 sendCommand.setString(maxHost);
|
|
314 smList.sendExcept(channel, sendCommand);
|
|
315 }
|
144
|
316
|
6
|
317 break;
|
144
|
318
|
8
|
319 case REP.SMCMD_UPDATE:
|
144
|
320
|
99
|
321 SessionXMLDecoder decoder3 = new SessionXMLDecoder();
|
|
322 SessionList receivedSessionList3 = decoder3.decode(receivedCommand.string);
|
144
|
323
|
122
|
324 //SessionListへ追加し変換テーブルを生成する。
|
163
|
325 //sessionlist.update(channel, receivedSessionList3);
|
179
|
326 sessionList.add(new Session(new Editor(channel)));
|
178
|
327
|
99
|
328 smList.sendExcept(channel, receivedCommand);
|
144
|
329
|
100
|
330 for(Session session3 : receivedSessionList3.getList()){
|
178
|
331 //gui.update();
|
100
|
332 gui.setComboSession(session3.getSID(), session3.getName());
|
|
333 }
|
144
|
334
|
9
|
335 break;
|
144
|
336
|
9
|
337 case REP.SMCMD_UPDATE_ACK:
|
164
|
338 if(receivedCommand.sid > sessionList.size()){
|
148
|
339 Editor editor = new Editor(channel);
|
75
|
340 editor.setName(receivedCommand.string);
|
144
|
341
|
158
|
342 Session session = new Session(editor);
|
73
|
343 session.addEditor(editor);
|
144
|
344
|
164
|
345 sessionList.add(session);
|
144
|
346
|
83
|
347 gui.setComboSession(session.getSID(), session.getName());
|
73
|
348 }
|
75
|
349 smList.sendToSlave(receivedCommand);
|
1
|
350 break;
|
144
|
351
|
95
|
352 case REP.SMCMD_CH_MASTER:
|
122
|
353 //maxHost を設定。
|
95
|
354 if(setMaxHost(channel, receivedCommand.string)){
|
|
355 sendCommand = new REPCommand();
|
|
356 sendCommand.setCMD(REP.SMCMD_CH_MASTER);
|
|
357 sendCommand.setString(maxHost);
|
|
358 smList.sendExcept(channel, sendCommand);
|
|
359 }
|
|
360 break;
|
144
|
361
|
0
|
362 default:
|
164
|
363 {
|
144
|
364 //sid から Session を取得
|
158
|
365 Session session = getSession(receivedCommand.sid);
|
144
|
366 //マージの処理と次のエディタへコマンドを送信する処理
|
|
367 session.translate(channel, receivedCommand);
|
164
|
368
|
178
|
369
|
167
|
370 Editor editor = session.getEditor(channel);
|
|
371 Editor prevEditor = session.getPrevEditor(editor);
|
|
372
|
179
|
373 //マージ中は前のエディタからのコマンドを受信しない
|
164
|
374 if(editor.isMerging()){
|
|
375 //Handlerを切り替える
|
167
|
376 setMergeState(prevEditor.getChannel(), session.getSID());
|
169
|
377 }else {
|
178
|
378 setNormalState(prevEditor.getChannel(), session.getSID());
|
164
|
379 }
|
|
380 }
|
144
|
381 break;
|
|
382 }
|
|
383 }
|
|
384
|
169
|
385 private void setNormalState(REPSocketChannel<REPCommand> channel, int sid) {
|
|
386 SelectionKey key = channel.keyFor(selector);
|
|
387 key.attach(new REPHandlerImpl(sid, this));
|
|
388 }
|
|
389
|
167
|
390 private void setMergeState(REPSocketChannel<REPCommand> channel, int sid) {
|
|
391 SelectionKey key = channel.keyFor(selector);
|
|
392 key.attach(new REPHandlerInMerge(sid, this));
|
164
|
393 }
|
|
394
|
160
|
395 private Editor getEditor(String hostport) {
|
178
|
396 for(Editor editor : editorList){
|
|
397 if(editor.getHost() == hostport){
|
|
398 return editor;
|
|
399 }
|
|
400 }
|
|
401 return null;
|
|
402 }
|
|
403
|
|
404 public Editor getEditor(REPSocketChannel channel){
|
|
405 for(Editor editor : editorList){
|
|
406 if(editor.getChannel() == channel){
|
|
407 return editor;
|
|
408 }
|
|
409 }
|
160
|
410 return null;
|
|
411 }
|
|
412
|
144
|
413 private Session getSession(int sid) {
|
|
414 for(Session session : sessionList){
|
|
415 if(session.getSID() == sid) return session;
|
|
416 }
|
|
417 return null;
|
0
|
418 }
|
83
|
419
|
139
|
420 private boolean setMaxHost(REPSocketChannel channel, String maxHost2) {
|
179
|
421 if(maxHost.compareTo(maxHost2) > 0){
|
|
422 return false;
|
|
423 }else{
|
|
424 maxHost = maxHost2;
|
|
425 return true;
|
|
426 }
|
139
|
427 }
|
|
428
|
76
|
429 private void setMyHostName(String localHostName) {
|
95
|
430 myHost = localHostName + temp_port;
|
81
|
431 if(maxHost == null) {
|
|
432 maxHost = myHost;
|
|
433 }
|
164
|
434 setHostToEditor(myHost);
|
|
435 }
|
|
436
|
|
437 private void setHostToEditor(String myHost2) {
|
|
438 for(Editor editor : editorList){
|
|
439 editor.setHost(myHost2);
|
|
440 }
|
76
|
441 }
|
0
|
442
|
|
443 public static void main(String[] args) throws InterruptedException, IOException {
|
191
|
444
|
|
445 REPServerSocketChannel.isSimulation = true;
|
|
446
|
101
|
447 int port = DEFAULT_PORT;
|
|
448 int port_s = DEFAULT_PORT;
|
113
|
449 //System.setProperty("file.encoding", "UTF-8");
|
82
|
450 if(args.length > 0){
|
39
|
451 port = Integer.parseInt(args[0]);
|
95
|
452 port_s = Integer.parseInt(args[1]);
|
0
|
453 }
|
95
|
454 temp_port = port;
|
|
455 send_port = port_s;
|
0
|
456 SessionManager sm = new SessionManager(port);
|
2
|
457 sm.openSelector();
|
155
|
458 sm.init(port);
|
191
|
459 sm.startGUI(sm);
|
155
|
460 sm.mainLoop();
|
191
|
461
|
0
|
462 }
|
|
463
|
191
|
464 private void startGUI(SessionManager sm) {
|
|
465 gui = new SessionManagerGUI(this);
|
83
|
466 Thread th = new Thread( gui );
|
2
|
467 th.start();
|
|
468 }
|
|
469
|
178
|
470 public void connectSession(String host) {
|
101
|
471 int port = DEFAULT_PORT;
|
95
|
472 port = send_port;
|
1
|
473 InetSocketAddress addr = new InetSocketAddress(host, port);
|
|
474 try {
|
186
|
475 REPSocketChannel<REPCommand> sessionchannel = REPSocketChannel.<REPCommand>create(new REPCommandPacker());
|
1
|
476 sessionchannel.configureBlocking(true);
|
|
477 sessionchannel.connect(addr);
|
6
|
478 while(!sessionchannel.finishConnect()){
|
77
|
479 System.out.print("test afro");
|
6
|
480 }
|
|
481 System.out.println("");
|
2
|
482 registerChannel(selector, sessionchannel, SelectionKey.OP_READ);
|
45
|
483
|
77
|
484 sm_join(sessionchannel);
|
45
|
485
|
1
|
486 }catch (IOException e) {
|
|
487 e.printStackTrace();
|
|
488 }
|
|
489 }
|
77
|
490
|
164
|
491 private void sm_join(REPSocketChannel<REPCommand> channel){
|
79
|
492
|
122
|
493 //SM_JOINコマンドを生成。
|
77
|
494 REPCommand command = new REPCommand();
|
|
495 command.setCMD(REP.SMCMD_SM_JOIN);
|
79
|
496
|
122
|
497 //hostnameをセット。
|
82
|
498 setMyHostName(getLocalHostName(channel));
|
|
499
|
122
|
500 //XMLを生成。送信コマンドにセット。
|
164
|
501 SessionXMLEncoder encoder = new SessionXMLEncoder(sessionList);
|
77
|
502 String string = encoder.sessionListToXML();
|
|
503 command.setString(string);
|
|
504
|
122
|
505 //SM_JOINコマンドを送信。
|
186
|
506 channel.write(command);
|
122
|
507 //SessionManagerのListに追加。
|
77
|
508 smList.add(channel);
|
|
509 }
|
2
|
510
|
139
|
511 private String getLocalHostName(REPSocketChannel channel) {
|
74
|
512 String host = null;
|
|
513 host = channel.socket().getLocalAddress().getHostName();
|
|
514 return host;
|
|
515 }
|
|
516
|
2
|
517 public void connectionOccured(ConnectionEvent event) {
|
178
|
518 try {
|
|
519 waitingQueue.put(event);
|
|
520 } catch (InterruptedException e) {
|
|
521 }
|
|
522 selector.wakeup();
|
2
|
523 }
|
8
|
524
|
|
525 public void ActionOccured(REPActionEvent event) {
|
104
|
526
|
163
|
527 REPSocketChannel<REPCommand> channel = event.getEditorChannel();
|
107
|
528 int sid = event.getSID();
|
164
|
529 Session session = getSession(sid);
|
158
|
530 if(session.hasOwner()){
|
148
|
531 Editor editor = new Editor(channel);
|
|
532 session.addEditor(new Editor(channel));
|
107
|
533 REPCommand sendCommand = new REPCommand();
|
|
534 sendCommand.setCMD(REP.SMCMD_JOIN_ACK);
|
148
|
535 sendCommand.setEID(editor.getEID());
|
107
|
536 sendCommand.setSID(sid);
|
186
|
537 channel.write(sendCommand);
|
107
|
538 }else {
|
164
|
539 REPSocketChannel<REPCommand> editorChannel = event.getEditorChannel();
|
107
|
540 sid = event.getSID();
|
|
541 Editor editor = new Editor(editorChannel);
|
|
542 editor.setHost(myHost);
|
164
|
543 session = getSession(sid);
|
107
|
544 session.addEditor(editor);
|
|
545
|
158
|
546 Editor owner = session.getOwner();
|
107
|
547
|
|
548 REPCommand command = new REPCommand();
|
|
549 command.setCMD(REP.SMCMD_SELECT);
|
|
550 command.setSID(sid);
|
178
|
551 command.setString(editor.getHost());
|
107
|
552 owner.send(command);
|
|
553 }
|
72
|
554
|
|
555
|
8
|
556 }
|
122
|
557
|
144
|
558 public void addWaitingCommand(PacketSet set) {
|
155
|
559 packetSetList.add(set);
|
144
|
560 }
|
148
|
561
|
185
|
562 public List<Session> getSessionList() {
|
|
563 // TODO Auto-generated method stub
|
|
564 return sessionList;
|
|
565 }
|
|
566
|
|
567 public List<Editor> getEditorList() {
|
|
568 // TODO Auto-generated method stub
|
|
569 return editorList;
|
|
570 }
|
|
571
|
0
|
572 }
|