Mercurial > hg > RemoteEditor > REPSessionManager
changeset 82:4bb583553a42
*** empty log message ***
author | pin |
---|---|
date | Tue, 11 Dec 2007 14:26:13 +0900 |
parents | 13819571691d |
children | 9381b4734a0b |
files | rep/SessionList.java rep/SessionManager.java rep/xml/SessionXMLEncoder.java |
diffstat | 3 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/SessionList.java Tue Dec 11 12:48:34 2007 +0900 +++ b/rep/SessionList.java Tue Dec 11 14:26:13 2007 +0900 @@ -280,7 +280,7 @@ maxHost = myHost; } - public String getHost() { + public String getMaxHost() { // TODO Auto-generated method stub return maxHost; }
--- a/rep/SessionManager.java Tue Dec 11 12:48:34 2007 +0900 +++ b/rep/SessionManager.java Tue Dec 11 14:26:13 2007 +0900 @@ -216,7 +216,7 @@ if(myHost == null) setMyHostName(getLocalHostName(channel)); //maxHost を設定。 - setMaxHost(channel, receivedSessionList.getHost()); + setMaxHost(channel, receivedSessionList.getMaxHost()); //SessionListからXMLを生成。 //joinしてきたSessionManagerに対してACKを送信。 @@ -239,10 +239,16 @@ break; case REP.SMCMD_SM_JOIN_ACK: + + //XMLからSessionListオブジェクトを生成。 + SessionXMLDecoder decoder2 = new SessionXMLDecoder(); + SessionList receivedSessionList2 = decoder2.decode(receivedCommand.string); + + //maxHostを決定。 + setMaxHost(channel, receivedSessionList2.getMaxHost()); + if(isMaster){ - smList.send(channel, receivedCommand); }else{ - smList.send(channel, receivedCommand); } break; @@ -300,7 +306,7 @@ maxHost = myHost; sessionlist.setMaxHost(maxHost); } - if(host.compareTo(maxHost) < 0){ + if(host.compareTo(maxHost) > 0){ //host > MaxHost なら maxHost = host //masterを設定する。 maxHost = host; @@ -330,7 +336,7 @@ public static void main(String[] args) throws InterruptedException, IOException { int port = 8766; - if(args.length == 1){ + if(args.length > 0){ port = Integer.parseInt(args[0]); } SessionManager sm = new SessionManager(port); @@ -374,8 +380,9 @@ command.setCMD(REP.SMCMD_SM_JOIN); //hostnameをセット。 - this.setMyHostName(getLocalHostName(channel)); - //this.setMaxHost(channel, getLocalHostName(channel)); + setMyHostName(getLocalHostName(channel)); + + //XMLを生成。送信コマンドにセット。 SessionXMLEncoder encoder = new SessionXMLEncoder(sessionlist); String string = encoder.sessionListToXML(); command.setString(string);
--- a/rep/xml/SessionXMLEncoder.java Tue Dec 11 12:48:34 2007 +0900 +++ b/rep/xml/SessionXMLEncoder.java Tue Dec 11 14:26:13 2007 +0900 @@ -22,7 +22,7 @@ private String sessionmanagerHost; public SessionXMLEncoder(SessionList sessionlist) { - sessionmanagerHost = sessionlist.getHost(); + sessionmanagerHost = sessionlist.getMaxHost(); this.list = sessionlist.getList(); }