Mercurial > hg > Members > nobuyasu > tightVNCClient
changeset 85:ba6e672cc47c
update EchoClient.java
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 06 Sep 2011 06:20:47 +0900 |
parents | 143c52bf3a94 |
children | 29e43be288ca |
files | src/myVncClient/EchoClient.java src/myVncClient/MyVncClient.java src/myVncClient/WaitReply.java |
diffstat | 3 files changed, 72 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/src/myVncClient/EchoClient.java Thu Sep 01 17:40:02 2011 +0900 +++ b/src/myVncClient/EchoClient.java Tue Sep 06 06:20:47 2011 +0900 @@ -7,20 +7,23 @@ public class EchoClient { - String name; - BufferedReader is = null; - DataOutputStream os = null; - Socket echoSocket = null; - boolean runflag = false; - WaitReply waitReply; + private String name; + private BufferedReader is = null; + private DataOutputStream os = null; + private Socket echoSocket = null; + private boolean runflag = false; + private WaitReply waitReply; + private Socket clientSocket = null; +// MyVncClient client; + private InterfaceForViewer client; + private int echoPort = 9999; + MyVncClient checkMove; + VncViewer vncV; String responseLine; String parent;// 親の番号 String treenum;// 自分の番号 String leaderflag;// リーダフラグ - Socket clientSocket = null; -// MyVncClient client; - InterfaceForViewer client; - int echoPort = 9999; + boolean passflag; // WaitReplyに自分自身を渡している @@ -39,12 +42,15 @@ this.echoPort = echoPort; } + + public EchoClient(EchoClient echo,MyVncClient client) { this.client = client; this.name = echo.name; leaderflag = echo.leaderflag; parent = echo.parent; treenum = echo.treenum; + waitReply = echo.waitReply; } public EchoClient(String name,CuiMyVncClient client) { @@ -174,20 +180,29 @@ * if ((value.treenum = is.readLine()) != null) { * System.out.println("treenum: " + value.treenum); } */ + + if(!(checkRepetition.equals("skip")) || "1".equals(leaderflag)) { + Thread.sleep(1000); + client.init(); + client.setEchoValue(this); + client.getParentName(); + client.start_threads(); + client.start(); + // MyVncClient.main(this); + + // 開いたソケットなどをクローズ + os.close(); + is.close(); + echoSocket.close(); + //runflag = true; + } + /* Thread.sleep(1000); - client.init(); - client.setEchoValue(this); - client.getParentName(); - client.start_threads(); - client.start(); -// MyVncClient.main(this); - - // 開いたソケットなどをクローズ - os.close(); - is.close(); - echoSocket.close(); - //runflag = true; - + if(checkRepetition.equals("skip") &&!(waitReply.passflag)) { + openport(); + notfoundParent(); + }*/ + } catch (UnknownHostException e) { System.err.println("Trying to connect to unknown host: " + e); } catch (IOException e) { @@ -236,12 +251,14 @@ System.out.println("parent: " + parent); } if ((treenum = is.readLine()) != null) { - System.out.println("Server: " + treenum); + System.out.println("treenum: " + treenum); } if ((leaderflag = is.readLine()) != null) { - System.out.println("parent: " + leaderflag); + System.out.println("leaderflag: " + leaderflag); } client.init(); + client.setEchoValue(this); + client.getParentName(); client.start_threads(); client.start(); os.close();
--- a/src/myVncClient/MyVncClient.java Thu Sep 01 17:40:02 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Tue Sep 06 06:20:47 2011 +0900 @@ -1137,37 +1137,37 @@ } public void getParentName() { - if (echoValue == null) { + if (echoValue == null) { - if (clientSocket == null) { + if (clientSocket == null) { -// echo = new EchoClient(pHost, this); - echoValue = new EchoClient(pHost, this, echoPort); - echoValue.openport(); + // echo = new EchoClient(pHost, this); + echoValue = new EchoClient(pHost, this, echoPort); + echoValue.openport(); - echoValue = echoValue.hostn("1"); - } else { - echoValue = new EchoClient(); - echoValue = echoValue.Interruption(clientSocket); + echoValue = echoValue.hostn("1"); + } else { + echoValue = new EchoClient(); + echoValue = echoValue.Interruption(clientSocket); + } } - } - // proxyからの返信で接続先を決定する - host = echoValue.responseLine; - parent = echoValue.parent; - if (echoValue.treenum != null) { - treenum = echoValue.treenum; - } else { - treenum = echoValue.treenum; - } - if (echoValue.leaderflag != null) { - leaderflag = echoValue.leaderflag; - } else { - leaderflag = echoValue.leaderflag; - } - System.out.println("Parent =" + parent); - System.out.println("mynumber =" + treenum); - System.out.println("connect host =" + host); - System.out.println("leaderflag(boolean) = " + leaderflag); + // proxyからの返信で接続先を決定する + host = echoValue.responseLine; + parent = echoValue.parent; + if (echoValue.treenum != null) { + treenum = echoValue.treenum; + } else { + treenum = echoValue.treenum; + } + if (echoValue.leaderflag != null) { + leaderflag = echoValue.leaderflag; + } else { + leaderflag = echoValue.leaderflag; + } + System.out.println("Parent =" + parent); + System.out.println("mynumber =" + treenum); + System.out.println("connect host =" + host); + System.out.println("leaderflag(boolean) = " + leaderflag); }
--- a/src/myVncClient/WaitReply.java Thu Sep 01 17:40:02 2011 +0900 +++ b/src/myVncClient/WaitReply.java Tue Sep 06 06:20:47 2011 +0900 @@ -7,6 +7,8 @@ // MyVncClient client; InterfaceForViewer client; private String treenum; + boolean passflag; + /* * public WaitReply(String treenum,MyVncClient client) { this.client = @@ -36,6 +38,7 @@ // client.clientSocket = clientSocket; client.setClientSocket(clientSocket); client.init(); + passflag = true; client.setEchoValue(null); client.getParentName(); client.start_threads();