Mercurial > hg > RemoteEditor > REPSessionManager
changeset 66:99196780bbf5
*** empty log message ***
author | pin |
---|---|
date | Fri, 16 Nov 2007 17:04:09 +0900 |
parents | 838a421963ba |
children | 13e4c3f2c6f9 |
files | rep/Session.java rep/SessionList.java rep/SessionManager.java |
diffstat | 3 files changed, 28 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/Session.java Fri Nov 16 16:38:52 2007 +0900 +++ b/rep/Session.java Fri Nov 16 17:04:09 2007 +0900 @@ -12,6 +12,7 @@ private String masterHost; private String masterPort; private LinkedList<REPNode> routingTable = new LinkedList<REPNode>(); + private int incrementEID; public Session(int sessionID, String string, SocketChannel channel) { masterEditor = new Editor(sessionID, channel); @@ -45,8 +46,10 @@ public String getName() { return sessionName; } - public void addEditor(Editor editor) { + public int addEditor(Editor editor) { + incrementEID++; editorList.add(editor); + return incrementEID; } public void setSID(int sessionID2) { sessionID = sessionID2; @@ -54,4 +57,7 @@ public void addToRoutingTable(Editor editor) { routingTable.add(new REPNode(editor)); } + public boolean isOwner() { + return true; + } }
--- a/rep/SessionList.java Fri Nov 16 16:38:52 2007 +0900 +++ b/rep/SessionList.java Fri Nov 16 17:04:09 2007 +0900 @@ -76,7 +76,7 @@ int editorID = repCmd.eid; // if(session3.get(sid) == null) System.out.println("ぬるぽ!"); // session3.get(sid).addEditor(editorID, channel); - sessionLinkedList.get(sid).addEditor(editorID, channel); //本当はforループで検索しないといけないよ。 + sessionLinkedList.get(sid-1).addEditor(editorID, channel); //本当はforループで検索しないといけないよ。 } public int getSessionID(SocketChannel channel) { @@ -270,4 +270,8 @@ } + public Session getSession(int sid) { + return sessionLinkedList.get(sid - 1); + } + }
--- a/rep/SessionManager.java Fri Nov 16 16:38:52 2007 +0900 +++ b/rep/SessionManager.java Fri Nov 16 17:04:09 2007 +0900 @@ -179,10 +179,22 @@ // break; case REP.SMCMD_SELECT: - sessionlist.addEditor(channel, repCmd.sid, repCmd); //sessionlistへ追加 - repCmd.setCMD(repCmd.cmd + 1); - REPPacketSend repSend3 = new REPPacketSend(channel); - repSend3.send(repCmd); //ACKを返す +// sessionlist.addEditor(channel, repCmd.sid, repCmd); //sessionlistへ追加 + Editor editor2 = new Editor(channel); + Session session2 = sessionlist.getSession(repCmd.sid); + if(session2.isOwner()){ + int eid = session2.addEditor(editor2); + editor2.setEID(eid); + REPPacketSend send = new REPPacketSend(channel); + repCmd.setEID(eid); + send.send(repCmd); + }else { + + } + +// repCmd.setCMD(REP.SMCMD_SELECT_ACK); +// REPPacketSend repSend3 = new REPPacketSend(channel); +// repSend3.send(repCmd); //ACKを返す break; case REP.SMCMD_SELECT_ACK: