Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/SessionManager.java @ 222:18d6a7140fa3
*** empty log message ***
author | pin |
---|---|
date | Sun, 31 Aug 2008 12:31:00 +0900 |
parents | 7649238aaf66 |
children | 6b0dd92b8e45 |
line wrap: on
line diff
--- a/rep/SessionManager.java Sun Aug 31 12:06:07 2008 +0900 +++ b/rep/SessionManager.java Sun Aug 31 12:31:00 2008 +0900 @@ -4,8 +4,6 @@ import java.net.InetSocketAddress; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; -import java.nio.channels.Selector; - import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -39,7 +37,7 @@ byte[] text; */ -public class SessionManager implements ConnectionListener, REPActionListener{ +public class SessionManager implements SessionManagerEventListener{ private LinkedList<Session> sessionList; private SessionManagerGUI gui; @@ -49,7 +47,6 @@ private boolean isMaster = true; private List<Editor> editorList; private String maxHost; - private boolean isSimulation; private List<PacketSet> waitingCommandInMerge; private BlockingQueue<SessionManagerEvent> waitingQueue; private static int temp_port; @@ -89,7 +86,8 @@ } continue; } - System.out.println(selector.select()); + int i = selector.select(); + System.out.println(i); select(); } } @@ -470,9 +468,10 @@ } private void startGUI(SessionManager sm) { - gui = new SessionManagerGUI(this); + gui = new SessionManagerGUI(); Thread th = new Thread( gui ); th.start(); + gui.addREPActionListener(this); } public void connectSession(String host) { @@ -522,28 +521,28 @@ return host; } - public void connectionOccured(ConnectionEvent event) { - try { - waitingQueue.put(event); - } catch (InterruptedException e) { - } - selector.wakeup(); - } +// public void connectionOccured(SessionManagerEvent event) { +// try { +// waitingQueue.put(event); +// } catch (InterruptedException e) { +// } +// selector.wakeup(); +// } +// +// public void selectOccured(SessionManagerEvent event) { +// try { +// waitingQueue.put(event); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// selector.wakeup(); +// } - public void selectOccured(REPActionEvent event) { - try { - waitingQueue.put(event); - } catch (InterruptedException e) { - e.printStackTrace(); - } - selector.wakeup(); - } - - public void selectSession(REPActionEvent event) { + public void selectSession(SelectButtonEvent event) { REPSocketChannel<REPCommand> channel = event.getEditorChannel(); int sid = event.getSID(); Session session = getSession(sid); - selector.wakeup(); + //selector.wakeup(); if(session.hasOwner()){ Editor editor = new Editor(channel); session.addEditor(new Editor(channel)); @@ -575,13 +574,19 @@ } public List<Session> getSessionList() { - // TODO Auto-generated method stub return sessionList; } public List<Editor> getEditorList() { - // TODO Auto-generated method stub return editorList; } + public void buttonPressed(SessionManagerEvent event) { + try { + waitingQueue.put(event); + } catch (InterruptedException e) {} + selector.wakeup(); + + } + }