Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/SessionList.java @ 1:3f5bf0255f5e
*** empty log message ***
author | pin |
---|---|
date | Wed, 21 Feb 2007 15:08:52 +0900 |
parents | e41994ce73c7 |
children | 02fa9a68d9a2 |
line wrap: on
line diff
--- a/rep/SessionList.java Tue Feb 13 04:43:30 2007 +0900 +++ b/rep/SessionList.java Wed Feb 21 15:08:52 2007 +0900 @@ -8,11 +8,12 @@ public class SessionList { //List<LinkedList<SocketChannel>> sessions = new LinkedList<LinkedList<SocketChannel>>(); - Hashtable<Integer, LinkedList<SocketChannel>> sessions2 = new Hashtable<Integer, LinkedList<SocketChannel>>(); - //Hashtable editors = new Hashtable(); - private int sessionID; + //Hashtable<Integer, LinkedList<SocketChannel>> sessions2 = new Hashtable<Integer, LinkedList<SocketChannel>>(); + Hashtable<Integer, Session> session3 = new Hashtable<Integer, Session>(); + private int sessionID = 0; + private int editorCount = 0; - private int editorCount; + private SocketChannel smchannel; public void add(SocketChannel channel) { @@ -29,17 +30,20 @@ public int addSession(SocketChannel channel, String string) { sessionID++; - sessions2.put(sessionID, new LinkedList<SocketChannel>()); + //sessions2.put(sessionID, new LinkedList<SocketChannel>()); //sessions.add(new LinkedList<SocketChannel>()); //return sessions2.size(); + session3.put(sessionID, new Session(sessionID, string, channel)); return sessionID; } - public void addEditor(SocketChannel channel, int sid) { + public void addEditor(SocketChannel channel, int sid, REPCommand repCmd) { + int editorID = repCmd.eid; //editorCount++; //sessions.get(sid-1).add(channel); - sessions2.get(sid).add(channel); + //sessions2.get(sid).add(channel); + session3.get(sid).addEditor(editorID, channel); } public int getSessionID(SocketChannel channel) { @@ -53,8 +57,10 @@ public void sendCmd(SocketChannel channel2, REPCommand repCmd) { //int sessionID = repCmd.sid; - LinkedList <SocketChannel> channelList = sessions2.get(repCmd.sid); - for(SocketChannel channel : channelList){ + //LinkedList <SocketChannel> channelList = sessions2.get(repCmd.sid); + LinkedList <Editor> editorList = session3.get(repCmd.sid).getEditorList(); + for(Editor editor : editorList){ + SocketChannel channel = editor.getChannel(); if(channel.equals(channel2)) { System.out.println("equals"); continue; @@ -64,4 +70,16 @@ } } + public void addSessionManager(SocketChannel channel, REPCommand repCmd) { + smchannel = channel; + + } + + public void sendAddedSession(REPCommand repCmd) { + // TODO Auto-generated method stub + repCmd.setCMD(REP.SMCMD_SESSION_JOIN); + REPPacketSend repSend = new REPPacketSend(smchannel); + //repSend.send(repCmd); + } + }