Mercurial > hg > RemoteEditor > REPSessionManager
changeset 152:2ce1a378da85
*** empty log message ***
author | pin |
---|---|
date | Thu, 28 Aug 2008 15:05:25 +0900 |
parents | 4ae9da03cf1e |
children | 4cfed12aa3aa |
files | rep/Editor.java rep/SessionManager.java |
diffstat | 2 files changed, 6 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/Editor.java Thu Aug 28 15:05:14 2008 +0900 +++ b/rep/Editor.java Thu Aug 28 15:05:25 2008 +0900 @@ -22,26 +22,32 @@ this.myChannel = channel; translater = new TranslaterImp1(eid); sentList = new LinkedList<REPCommand>(); + setHostAndPort(myChannel); } public Editor(REPSocketChannel<REPCommand> channel) { this.myChannel = channel; setHostAndPort(myChannel); + translater = new TranslaterImp1(eid); + sentList = new LinkedList<REPCommand>(); } public LinkedList<REPCommand> translate(REPCommand command){ LinkedList<REPCommand> list = new LinkedList<REPCommand>(); if(command.eid == eid){ if(checkReturnedCommand(command)){ + //エディタからのコマンドが元のエディタに戻ってきた REPCommand[] cmds = translater.catchOwnCommand(command); sendMergedCommand(cmds); return null; }else{ + //エディタからの新たな編集コマンド sentList.add(command); translater.transSendCmd(command); list.add(command); } }else{ + //他のエディタからの編集コマンド REPCommand[] cmds = translater.transReceiveCmd(command); for(REPCommand cmd : cmds){ list.add(cmd);
--- a/rep/SessionManager.java Thu Aug 28 15:05:14 2008 +0900 +++ b/rep/SessionManager.java Thu Aug 28 15:05:25 2008 +0900 @@ -127,7 +127,6 @@ channel.configureBlocking(false); selector.wakeup(); REPHandler handler = new REPHandlerImpl(this); - //channel.register(selector, ops); channel.register(selector, ops, handler); } @@ -377,24 +376,6 @@ return false; } - private int reverseCmd(int cmd) { - int kindOfCmd = 0; - switch(cmd){ - case REP.REPCMD_INSERT: - kindOfCmd = REP.REPCMD_DELETE; - break; - case REP.REPCMD_DELETE: - kindOfCmd = REP.REPCMD_INSERT; - break; - case REP.REPCMD_REPLACE: - kindOfCmd = REP.REPCMD_REPLACE; - break; - } - return kindOfCmd; - } - - - private void setMyHostName(String localHostName) { myHost = localHostName + temp_port; if(maxHost == null) { @@ -404,12 +385,6 @@ ownEditorList.setHost(myHost); } - private void setMaster(boolean b, REPSocketChannel channel) { - isMaster = b; - System.out.println("isMaster = " + b); - smList.setMaster(channel); - } - public static void main(String[] args) throws InterruptedException, IOException { int port = DEFAULT_PORT; int port_s = DEFAULT_PORT;