Mercurial > hg > RemoteEditor > REPSessionManager
view rep/EditorList.java @ 23:01657c033761
*** empty log message ***
author | pin |
---|---|
date | Thu, 08 Nov 2007 17:19:45 +0900 |
parents | 850a9cc4963a |
children | 7012a944e58f |
line wrap: on
line source
package rep; import java.nio.channels.SocketChannel; import java.util.LinkedList; public class EditorList { private int numberOfEditor; private LinkedList<Editor> editorList = new LinkedList<Editor>(); public void sendJoinAck(REPCommand repCmd) { Editor editor = null; for(Editor editor2 : editorList){ if(editor2.getEID() == repCmd.eid){ editor = editor2; } } if(editor == null){System.out.println("error");} REPPacketSend send = new REPPacketSend(editor.getChannel()); send.send(repCmd); } public void sendJoinAck(SocketChannel channel, REPCommand repCmd) { REPCommand command = repCmd; command.setCMD(REP.SMCMD_JOIN_ACK); REPPacketSend send = new REPPacketSend(channel); send.send(command); } public int addEditor(SocketChannel channel, REPCommand repCmd) { numberOfEditor++; editorList.add(new Editor(numberOfEditor, channel)); return numberOfEditor; } public void addEditor(SocketChannel channel) { editorList.add(new Editor(0, channel)); } public void setEID(REPCommand repCmd) { for(Editor editor : editorList){ if(editor.getEID() == 0){ editor.setEID(repCmd.eid); break; } } } }