Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/SessionList.java @ 0:e41994ce73c7
*** empty log message ***
author | pin |
---|---|
date | Tue, 13 Feb 2007 04:43:30 +0900 |
parents | |
children | 3f5bf0255f5e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e41994ce73c7 |
---|---|
1 package rep; | |
2 | |
3 import java.nio.channels.SocketChannel; | |
4 import java.util.Hashtable; | |
5 import java.util.LinkedList; | |
6 import java.util.List; | |
7 | |
8 public class SessionList { | |
9 | |
10 //List<LinkedList<SocketChannel>> sessions = new LinkedList<LinkedList<SocketChannel>>(); | |
11 Hashtable<Integer, LinkedList<SocketChannel>> sessions2 = new Hashtable<Integer, LinkedList<SocketChannel>>(); | |
12 //Hashtable editors = new Hashtable(); | |
13 private int sessionID; | |
14 | |
15 private int editorCount; | |
16 | |
17 public void add(SocketChannel channel) { | |
18 | |
19 } | |
20 | |
21 public int getEditorNumber() { | |
22 return 0; | |
23 | |
24 } | |
25 | |
26 public void add(SocketChannel channel, int sid) { | |
27 | |
28 } | |
29 | |
30 public int addSession(SocketChannel channel, String string) { | |
31 sessionID++; | |
32 sessions2.put(sessionID, new LinkedList<SocketChannel>()); | |
33 //sessions.add(new LinkedList<SocketChannel>()); | |
34 //return sessions2.size(); | |
35 return sessionID; | |
36 | |
37 } | |
38 | |
39 public void addEditor(SocketChannel channel, int sid) { | |
40 //editorCount++; | |
41 //sessions.get(sid-1).add(channel); | |
42 sessions2.get(sid).add(channel); | |
43 } | |
44 | |
45 public int getSessionID(SocketChannel channel) { | |
46 return 0; | |
47 } | |
48 | |
49 public int getNumberOfEditor() { | |
50 editorCount++; | |
51 return editorCount; | |
52 } | |
53 | |
54 public void sendCmd(SocketChannel channel2, REPCommand repCmd) { | |
55 //int sessionID = repCmd.sid; | |
56 LinkedList <SocketChannel> channelList = sessions2.get(repCmd.sid); | |
57 for(SocketChannel channel : channelList){ | |
58 if(channel.equals(channel2)) { | |
59 System.out.println("equals"); | |
60 continue; | |
61 } | |
62 REPPacketSend repSend = new REPPacketSend(channel); | |
63 repSend.send(repCmd); | |
64 } | |
65 } | |
66 | |
67 } |