# HG changeset patch # User pin # Date 1219905560 -32400 # Node ID bbd2801d8ce06506e6aaa41412a7dc7b89463c1a # Parent fafbaaa0abd0684cef9e5631b1a5ec8ec237d148 *** empty log message *** diff -r fafbaaa0abd0 -r bbd2801d8ce0 rep/Editor.java --- a/rep/Editor.java Thu Aug 28 15:33:02 2008 +0900 +++ b/rep/Editor.java Thu Aug 28 15:39:20 2008 +0900 @@ -16,6 +16,12 @@ private String file; private TranslaterImp1 translater; private List sentList; + + public Editor(){ + setHostAndPort(myChannel); + translater = new TranslaterImp1(eid); + sentList = new LinkedList(); + } public Editor(int editorNo, REPSocketChannel channel){ this.eid = editorNo; @@ -89,7 +95,6 @@ } public REPSocketChannel getChannel() { - return myChannel; } @@ -116,7 +121,6 @@ } public String toString(){ return (host + ":" + port + ":" + file); - //return ("eid:" + eid + ":" + myChannel.socket().getLocalSocketAddress().toString()); } public String getName() { diff -r fafbaaa0abd0 -r bbd2801d8ce0 rep/SessionManager.java --- a/rep/SessionManager.java Thu Aug 28 15:33:02 2008 +0900 +++ b/rep/SessionManager.java Thu Aug 28 15:39:20 2008 +0900 @@ -56,6 +56,7 @@ private List editorList; private String maxHost; private boolean isSimulation; + private List packetSetList; //private Set sessionList; private static int temp_port; private static int send_port; @@ -70,14 +71,11 @@ selector = REPSelector.open(); } - public void mainLoop(int port) throws InterruptedException, IOException { + public void init(int port) throws InterruptedException, IOException { REPServerSocketChannel ssc = REPServerSocketChannel.open(); - ssc.configureBlocking(false); //reuse address 必須 - ssc.socket().setReuseAddress(true); - ssc.socket().bind(new InetSocketAddress(port)); ssc.register(selector, SelectionKey.OP_ACCEPT); @@ -87,7 +85,13 @@ smList = new SessionManagerList(); ownEditorList = new EditorList(); editorList = new LinkedList(); + packetSetList = new LinkedList(); + // main loop + mainLoop(); + } + + private void mainLoop() throws IOException { while(true){ selector.select(); select(); @@ -398,7 +402,8 @@ SessionManager sm = new SessionManager(port); sm.openSelector(); sm.openWindow(); - sm.mainLoop(port); + sm.init(port); + sm.mainLoop(); } private void openWindow() { @@ -498,7 +503,7 @@ public void addWaitingCommand(PacketSet set) { // TODO Auto-generated method stub - + packetSetList.add(set); } public void undo() { diff -r fafbaaa0abd0 -r bbd2801d8ce0 rep/handler/PacketSet.java --- a/rep/handler/PacketSet.java Thu Aug 28 15:33:02 2008 +0900 +++ b/rep/handler/PacketSet.java Thu Aug 28 15:39:20 2008 +0900 @@ -2,13 +2,14 @@ import rep.REPCommand; import rep.channel.ChannelSimulator; +import rep.channel.REPSocketChannel; public class PacketSet { - private ChannelSimulator channel; + private REPSocketChannel channel; private REPCommand packet; - public PacketSet(ChannelSimulator channel, REPCommand packet) { + public PacketSet(REPSocketChannel channel, REPCommand packet) { this.channel = channel; this.packet = packet; } diff -r fafbaaa0abd0 -r bbd2801d8ce0 rep/handler/REPHandlerImpl.java --- a/rep/handler/REPHandlerImpl.java Thu Aug 28 15:33:02 2008 +0900 +++ b/rep/handler/REPHandlerImpl.java Thu Aug 28 15:39:20 2008 +0900 @@ -1,5 +1,6 @@ package rep.handler; +import java.io.IOException; import java.nio.channels.SelectionKey; import rep.REPCommand; @@ -17,7 +18,7 @@ this.manager = manager; } - public void handle(SelectionKeySimulator key) { + public void handle(SelectionKeySimulator key) throws IOException { REPSocketChannel channel = (REPSocketChannel) key.channel(); REPCommand packet = channel.read(); REPCommand command = packet; diff -r fafbaaa0abd0 -r bbd2801d8ce0 rep/handler/REPHandlerInMerge.java --- a/rep/handler/REPHandlerInMerge.java Thu Aug 28 15:33:02 2008 +0900 +++ b/rep/handler/REPHandlerInMerge.java Thu Aug 28 15:39:20 2008 +0900 @@ -1,9 +1,11 @@ package rep.handler; +import java.io.IOException; import java.nio.channels.SelectionKey; import rep.REPCommand; import rep.SessionManager; import rep.channel.ChannelSimulator; +import rep.channel.REPSocketChannel; import rep.channel.SelectionKeySimulator; public class REPHandlerInMerge implements REPHandler { @@ -15,8 +17,8 @@ this.manager = manager; } - public void handle(SelectionKeySimulator key) { - ChannelSimulator channel = (ChannelSimulator) key.channel(); + public void handle(SelectionKeySimulator key) throws IOException { + REPSocketChannel channel = (REPSocketChannel) key.channel(); REPCommand packet = channel.read(); manager.addWaitingCommand(new PacketSet(channel, packet)); REPCommand command = packet;