Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/Session.java @ 320:83790b8b8174
*** empty log message ***
author | kono |
---|---|
date | Fri, 10 Oct 2008 14:10:15 +0900 |
parents | dfed28488274 |
children | 5893fd8c0f50 |
line wrap: on
line diff
--- a/rep/Session.java Thu Oct 09 17:26:55 2008 +0900 +++ b/rep/Session.java Fri Oct 10 14:10:15 2008 +0900 @@ -17,26 +17,24 @@ this(sid, editor); sessionName = name; } + public Session(Editor editor) { - masterEditor = editor; - this.sessionID = 0; - this.sessionName = editor.getName(); - if(editor.channel!=null) firstForwarder = editor; + this(0,editor.getName(),editor); } public Session(int sid, Forwarder editor) { sessionID = sid; - masterEditor = editor; - editorList.add(editor); - if(editor.channel!=null) firstForwarder = editor; - } - - public void addEditor(SessionManager manager,int editorID, REPSocketChannel<REPCommand> channel) { - Editor editor =new Editor(manager,editorID, channel); - addForwarder(editor); + if (editor!=null) { + // we have a master + masterEditor = editor; + editor.setSID(sid); + editorList.add(editor); + if(editor.channel!=null) firstForwarder = editor; + } } public void addForwarder(Forwarder forwarder) { + // add a forwarder and connect this to the session Forwarder last = (Forwarder)editorList.getLast(); forwarder.setNext(last.getNextForwarder()); last.setNext(forwarder); @@ -44,6 +42,12 @@ if(firstForwarder==null) firstForwarder = forwarder; } + public void addEditor(Editor editor) { + // add a not-connected editor in a sassion + // the editor is outside of this manager + editorList.add(editor); + } + public LinkedList<EditorPlus> getEditorList() { return editorList; } @@ -107,7 +111,7 @@ } public void hasOwner(boolean b) { - isOwner = true; + isOwner = b; } public Editor getEditor(REPSocketChannel<REPCommand> channel) { @@ -142,7 +146,5 @@ return firstForwarder; } - public void addEditor(Editor editor) { - editorList.add(editor); - } + }