Mercurial > hg > RemoteEditor > REPSessionManager
view rep/SessionManagerList.java @ 217:4deaaaa6354e
*** empty log message ***
author | kono |
---|---|
date | Sun, 31 Aug 2008 00:26:35 +0900 |
parents | eb89a73976fa |
children | 90965a3bd4f3 |
line wrap: on
line source
package rep; import java.util.LinkedList; import java.util.List; import rep.channel.REPSocketChannel; import rep.xml.SessionXMLEncoder; public class SessionManagerList { private List<REPSocketChannel<REPCommand>> list = new LinkedList<REPSocketChannel<REPCommand>>(); private int mySMID; private REPSocketChannel<REPCommand> master; public void add(REPSocketChannel<REPCommand> channel) { list.add(channel); } public void sendUpdate(int sessionID, String string) { for(REPSocketChannel<REPCommand> channel : list){ channel.write(new REPCommand(REP.SMCMD_UPDATE, 0, mySMID, 0, 0, string.length(), string)); } } public void sendJoin(REPCommand command) { for(REPSocketChannel<REPCommand> channel : list){ channel.write(command); } } public void setMaster(REPSocketChannel<REPCommand> channel){ this.master = channel; } public void sendSessionList(SessionList sessionlist, REPCommand command) { SessionXMLEncoder encoder = new SessionXMLEncoder(sessionlist); command.setString(encoder.sessionListToXML()); for(REPSocketChannel<REPCommand> channel : list){ channel.write(command); } } public void send(REPSocketChannel<REPCommand> channel, REPCommand repCmd) { } public void sendToMaster(REPCommand repCmd) { master.write(repCmd); } public void sendToSlave(REPCommand repCmd) { for(REPSocketChannel<REPCommand> channel : list){ if(channel.equals(master)) continue; channel.write(repCmd); } } public void sendExcept(REPSocketChannel<REPCommand> channel2, REPCommand command) { for(REPSocketChannel<REPCommand> channel : list){ if(channel.equals(channel2)) continue; channel.write(command); } } }