Mercurial > hg > RemoteEditor > REPSessionManager
view rep/SessionManagerList.java @ 328:6ceb222570cb
merge is working now.
author | kono |
---|---|
date | Sat, 11 Oct 2008 22:23:45 +0900 |
parents | 90965a3bd4f3 |
children | 21ad256c25c2 |
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)); } } 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); } } }