Mercurial > hg > RemoteEditor > REPSessionManager
changeset 357:6ae9dcb30a12
*** empty log message ***
author | kono |
---|---|
date | Sat, 18 Oct 2008 21:28:17 +0900 |
parents | b18c24dcc5d2 |
children | 034acadc0cdc |
files | rep/SessionList.java |
diffstat | 1 files changed, 18 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/SessionList.java Sat Oct 18 19:01:40 2008 +0900 +++ b/rep/SessionList.java Sat Oct 18 21:28:17 2008 +0900 @@ -5,37 +5,20 @@ import rep.channel.REPSocketChannel; import rep.xml.SessionXMLEncoder; -public class SessionList { +public class SessionList extends LinkedList<Session>{ - LinkedList<Session> sessionLinkedList = new LinkedList<Session>(); + /** + * + */ + private static final long serialVersionUID = 1L; LinkedList<String> stringlist = new LinkedList<String>(); - private int sessionID = 0; - private int editorCount = 0; private String maxHost; + private int sid_root = 0; - public int addSession(REPSocketChannel<REPCommand> channel, String string) { - sessionID++; - return sessionID; - - } - - public int getNumberOfEditor() { - editorCount++; - return editorCount; - } - - public String getSessionList() { - if (sessionLinkedList != null) { - SessionManager.logger.writeLog( - sessionLinkedList.toString()); - return sessionLinkedList.toString(); - } - return "{}"; - } public void sendSelect(int sid) { - REPSocketChannel<REPCommand> channel = sessionLinkedList.get(sid-1).getOwner().getChannel(); + REPSocketChannel<REPCommand> channel = get(sid-1).getOwner().getChannel(); channel.write(new REPCommand(REP.SMCMD_SELECT, sid, 0, 0, 0, "")); } @@ -106,29 +89,29 @@ // }*/ public LinkedList<Session> getList() { - return sessionLinkedList; + return new LinkedList<Session>(this); } public String toXML() { - SessionXMLEncoder encoder = new SessionXMLEncoder(sessionLinkedList); + SessionXMLEncoder encoder = new SessionXMLEncoder(this); encoder.sessionListToXML(); return null; } public int addSession(Session session) { - sessionID++; - session.setSID(sessionID); - sessionLinkedList.add(session); - return sessionID; + int sid; + session.setSID(sid=newSessionID()); + add(session); + return sid; } public Session getSession(int sid) { - for(Session session : sessionLinkedList){ + for(Session session : this){ if(session.getSID() == sid){ return session; } } - return sessionLinkedList.get(sid - 1); + return get(sid - 1); } public void setMaxHost(String myHost) { @@ -139,8 +122,9 @@ return maxHost; } - public void setList(LinkedList<Session> list) { - sessionLinkedList = list; + + public int newSessionID() { + return ++sid_root ; } }