Mercurial > hg > RemoteEditor > REPSessionManager
view rep/Session.java @ 82:4bb583553a42
*** empty log message ***
author | pin |
---|---|
date | Tue, 11 Dec 2007 14:26:13 +0900 |
parents | 248d774be113 |
children | f0bc200d963d |
line wrap: on
line source
package rep; import java.nio.channels.SocketChannel; import java.util.LinkedList; import java.util.List; public class Session { private Editor masterEditor; private int sessionID; private String sessionName; private LinkedList<Editor> editorList = new LinkedList<Editor>(); private String masterHost; private String masterPort; private LinkedList<REPNode> routingTable = new LinkedList<REPNode>(); private int incrementEID; private boolean isOwner = false; public Session(int sessionID, String string, SocketChannel channel) { masterEditor = new Editor(sessionID, channel); this.sessionID = sessionID; this.sessionName = string; } public Session(Editor editor) { masterEditor = editor; masterHost = editor.getHost(); masterPort = editor.getPort(); this.sessionID = 0; this.sessionName = editor.getName(); } public void addEditor(int editorID, SocketChannel channel) { editorList.add(new Editor(editorID, channel)); } public LinkedList<Editor> getEditorList() { if(editorList == null) System.out.println("null!"); return editorList; } public String toString(){ return sessionName; } public int getSID() { return sessionID; } public Editor getMaster() { return masterEditor; } public String getName() { return sessionName; } public int addEditor(Editor editor) { incrementEID++; editorList.add(editor); return incrementEID; } public void setSID(int sessionID2) { sessionID = sessionID2; } public void addToRoutingTable(Editor editor) { routingTable.add(new REPNode(editor)); } public boolean isOwner() { return isOwner; } public void setOwner(boolean b) { isOwner = true; } public void sendToEditor(REPCommand repCmd) { for(Editor editor : editorList){ REPPacketSend send = new REPPacketSend(editor.getChannel()); send.send(repCmd); } } }