Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/SessionList.java @ 357:6ae9dcb30a12
*** empty log message ***
author | kono |
---|---|
date | Sat, 18 Oct 2008 21:28:17 +0900 |
parents | 5ba5b7a9761b |
children | 034acadc0cdc |
comparison
equal
deleted
inserted
replaced
356:b18c24dcc5d2 | 357:6ae9dcb30a12 |
---|---|
3 import java.util.LinkedList; | 3 import java.util.LinkedList; |
4 | 4 |
5 import rep.channel.REPSocketChannel; | 5 import rep.channel.REPSocketChannel; |
6 import rep.xml.SessionXMLEncoder; | 6 import rep.xml.SessionXMLEncoder; |
7 | 7 |
8 public class SessionList { | 8 public class SessionList extends LinkedList<Session>{ |
9 | 9 |
10 LinkedList<Session> sessionLinkedList = new LinkedList<Session>(); | 10 /** |
11 * | |
12 */ | |
13 private static final long serialVersionUID = 1L; | |
11 LinkedList<String> stringlist = new LinkedList<String>(); | 14 LinkedList<String> stringlist = new LinkedList<String>(); |
12 private int sessionID = 0; | |
13 private int editorCount = 0; | |
14 private String maxHost; | 15 private String maxHost; |
16 private int sid_root = 0; | |
15 | 17 |
16 | 18 |
17 public int addSession(REPSocketChannel<REPCommand> channel, String string) { | |
18 sessionID++; | |
19 return sessionID; | |
20 | |
21 } | |
22 | |
23 public int getNumberOfEditor() { | |
24 editorCount++; | |
25 return editorCount; | |
26 } | |
27 | |
28 public String getSessionList() { | |
29 if (sessionLinkedList != null) { | |
30 SessionManager.logger.writeLog( | |
31 sessionLinkedList.toString()); | |
32 return sessionLinkedList.toString(); | |
33 } | |
34 return "{}"; | |
35 } | |
36 | 19 |
37 public void sendSelect(int sid) { | 20 public void sendSelect(int sid) { |
38 REPSocketChannel<REPCommand> channel = sessionLinkedList.get(sid-1).getOwner().getChannel(); | 21 REPSocketChannel<REPCommand> channel = get(sid-1).getOwner().getChannel(); |
39 channel.write(new REPCommand(REP.SMCMD_SELECT, sid, 0, 0, 0, "")); | 22 channel.write(new REPCommand(REP.SMCMD_SELECT, sid, 0, 0, 0, "")); |
40 } | 23 } |
41 | 24 |
42 // public String getXML() { | 25 // public String getXML() { |
43 ///* SessionListをXMLに書き出す。ときの形式 | 26 ///* SessionListをXMLに書き出す。ときの形式 |
104 // } | 87 // } |
105 // return str.toString(); | 88 // return str.toString(); |
106 // }*/ | 89 // }*/ |
107 | 90 |
108 public LinkedList<Session> getList() { | 91 public LinkedList<Session> getList() { |
109 return sessionLinkedList; | 92 return new LinkedList<Session>(this); |
110 } | 93 } |
111 | 94 |
112 public String toXML() { | 95 public String toXML() { |
113 SessionXMLEncoder encoder = new SessionXMLEncoder(sessionLinkedList); | 96 SessionXMLEncoder encoder = new SessionXMLEncoder(this); |
114 encoder.sessionListToXML(); | 97 encoder.sessionListToXML(); |
115 return null; | 98 return null; |
116 } | 99 } |
117 | 100 |
118 public int addSession(Session session) { | 101 public int addSession(Session session) { |
119 sessionID++; | 102 int sid; |
120 session.setSID(sessionID); | 103 session.setSID(sid=newSessionID()); |
121 sessionLinkedList.add(session); | 104 add(session); |
122 return sessionID; | 105 return sid; |
123 } | 106 } |
124 | 107 |
125 public Session getSession(int sid) { | 108 public Session getSession(int sid) { |
126 for(Session session : sessionLinkedList){ | 109 for(Session session : this){ |
127 if(session.getSID() == sid){ | 110 if(session.getSID() == sid){ |
128 return session; | 111 return session; |
129 } | 112 } |
130 } | 113 } |
131 return sessionLinkedList.get(sid - 1); | 114 return get(sid - 1); |
132 } | 115 } |
133 | 116 |
134 public void setMaxHost(String myHost) { | 117 public void setMaxHost(String myHost) { |
135 maxHost = myHost; | 118 maxHost = myHost; |
136 } | 119 } |
137 | 120 |
138 public String getMaxHost() { | 121 public String getMaxHost() { |
139 return maxHost; | 122 return maxHost; |
140 } | 123 } |
141 | 124 |
142 public void setList(LinkedList<Session> list) { | 125 |
143 sessionLinkedList = list; | 126 public int newSessionID() { |
127 return ++sid_root ; | |
144 } | 128 } |
145 | 129 |
146 } | 130 } |