Mercurial > hg > RemoteEditor > REPSessionManager
changeset 101:612cb62151ce
*** empty log message ***
author | pin |
---|---|
date | Sat, 22 Dec 2007 13:54:45 +0900 |
parents | 25bf89525e70 |
children | 1773abed1fc8 |
files | rep/SessionList.java rep/SessionManager.java |
diffstat | 2 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/SessionList.java Sat Dec 22 11:07:01 2007 +0900 +++ b/rep/SessionList.java Sat Dec 22 13:54:45 2007 +0900 @@ -294,6 +294,7 @@ LinkedList<Session> list = receivedSessionList.getList(); int i = 0; for(Session session : list){ + session.getEditorList().get(0).setChannel(channel); ++i; int sid = addSession(session); setTranslationTable(channel, i, sid);
--- a/rep/SessionManager.java Sat Dec 22 11:07:01 2007 +0900 +++ b/rep/SessionManager.java Sat Dec 22 13:54:45 2007 +0900 @@ -20,11 +20,11 @@ //+-------+--------+--------+-------+--------+---------+------+ //o-------header section (network order)-------------o /*int cmd; // command -int sid; // session ID -int eid; // editor ID -int seqno; // Sequence number +int sid; // session ID : uniqu to editing file +int eid; // editor ID : owner editor ID = 1。Session に対してユニーク +int seqno; // Sequence number : sequence number はエディタごとに管理 int lineno; // line number -int textsize; // textsize +int textsize; // textsize : bytesize byte[] text;*/ public class SessionManager implements ConnectionListener, REPActionListener{ @@ -44,6 +44,9 @@ //private boolean co; private static int temp_port; private static int send_port; + + static final int DEFAULT_PORT = 8766; + public SessionManager(int port) { gui = new SessionManagerGUI(); } @@ -55,7 +58,10 @@ public void sessionManagerNet(int port) throws InterruptedException, IOException { ServerSocketChannel ssc = ServerSocketChannel.open(); - ssc.configureBlocking(false); + ssc.configureBlocking(false); //reuse address 必須 + + ssc.socket().setReuseAddress(true); + ssc.socket().bind(new InetSocketAddress(port)); ssc.register(selector, SelectionKey.OP_ACCEPT); @@ -407,8 +413,8 @@ } public static void main(String[] args) throws InterruptedException, IOException { - int port = 8766; - int port_s = 8766; + int port = DEFAULT_PORT; + int port_s = DEFAULT_PORT; if(args.length > 0){ port = Integer.parseInt(args[0]); @@ -431,7 +437,7 @@ } private void connectSession(String host) { - int port = 8766; + int port = DEFAULT_PORT; port = send_port; InetSocketAddress addr = new InetSocketAddress(host, port); try {