Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/EditorList.java @ 23:01657c033761
*** empty log message ***
author | pin |
---|---|
date | Thu, 08 Nov 2007 17:19:45 +0900 |
parents | 850a9cc4963a |
children | 7012a944e58f |
comparison
equal
deleted
inserted
replaced
22:850a9cc4963a | 23:01657c033761 |
---|---|
1 package rep; | 1 package rep; |
2 | |
3 import java.nio.channels.SocketChannel; | |
4 import java.util.LinkedList; | |
2 | 5 |
3 public class EditorList { | 6 public class EditorList { |
4 | 7 |
8 private int numberOfEditor; | |
9 private LinkedList<Editor> editorList = new LinkedList<Editor>(); | |
10 | |
5 public void sendJoinAck(REPCommand repCmd) { | 11 public void sendJoinAck(REPCommand repCmd) { |
6 // TODO Auto-generated method stub | 12 Editor editor = null; |
7 | 13 for(Editor editor2 : editorList){ |
14 if(editor2.getEID() == repCmd.eid){ | |
15 editor = editor2; | |
16 } | |
17 } | |
18 if(editor == null){System.out.println("error");} | |
19 REPPacketSend send = new REPPacketSend(editor.getChannel()); | |
20 send.send(repCmd); | |
8 } | 21 } |
9 | 22 |
10 public void addEditor(REPCommand repCmd) { | 23 public void sendJoinAck(SocketChannel channel, REPCommand repCmd) { |
11 // TODO Auto-generated method stub | 24 REPCommand command = repCmd; |
25 command.setCMD(REP.SMCMD_JOIN_ACK); | |
12 | 26 |
27 REPPacketSend send = new REPPacketSend(channel); | |
28 send.send(command); | |
29 } | |
30 | |
31 public int addEditor(SocketChannel channel, REPCommand repCmd) { | |
32 numberOfEditor++; | |
33 editorList.add(new Editor(numberOfEditor, channel)); | |
34 return numberOfEditor; | |
35 } | |
36 | |
37 public void addEditor(SocketChannel channel) { | |
38 editorList.add(new Editor(0, channel)); | |
39 } | |
40 | |
41 public void setEID(REPCommand repCmd) { | |
42 for(Editor editor : editorList){ | |
43 if(editor.getEID() == 0){ | |
44 editor.setEID(repCmd.eid); | |
45 break; | |
46 } | |
47 } | |
13 } | 48 } |
14 | 49 |
15 } | 50 } |