Mercurial > hg > Members > nobuyasu > tightVNCClient
changeset 86:29e43be288ca
merge
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 06 Sep 2011 06:23:20 +0900 |
parents | ba6e672cc47c (diff) 7aea720eb485 (current diff) |
children | 6c43d40abfe6 |
files | src/myVncClient/EchoClient.java src/myVncClient/MyRfbProto.java |
diffstat | 4 files changed, 64 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/myVncClient/EchoClient.java Wed Aug 31 19:08:00 2011 +0900 +++ b/src/myVncClient/EchoClient.java Tue Sep 06 06:23:20 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) { @@ -175,7 +181,9 @@ * System.out.println("treenum: " + value.treenum); } */ - if(!(checkRepetition.equals("skip"))) { + + if(!(checkRepetition.equals("skip")) || "1".equals(leaderflag)) { + Thread.sleep(1000); client.init(); client.setEchoValue(this); @@ -191,6 +199,14 @@ //runflag = true; } + /* + Thread.sleep(1000); + if(checkRepetition.equals("skip") &&!(waitReply.passflag)) { + openport(); + notfoundParent(); + }*/ + + } catch (UnknownHostException e) { System.err.println("Trying to connect to unknown host: " + e); } catch (IOException e) { @@ -239,12 +255,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/MyRfbProto.java Wed Aug 31 19:08:00 2011 +0900 +++ b/src/myVncClient/MyRfbProto.java Tue Sep 06 06:23:20 2011 +0900 @@ -138,7 +138,7 @@ void changeParent(String h, int p) throws IOException { host = h; port = p; - + sock = new Socket(host, port); is = new DataInputStream(new BufferedInputStream(sock.getInputStream(), 16384));
--- a/src/myVncClient/MyVncClient.java Wed Aug 31 19:08:00 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Tue Sep 06 06:23:20 2011 +0900 @@ -132,6 +132,8 @@ }else { System.out.println("reConnectAndAuthenticate() "); reConnectAndAuthenticate(); + accThread = new Thread(new AcceptThread(rfb, 5999)); + accThread.start(); } doProtocolInitialisation(); @@ -1135,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 Wed Aug 31 19:08:00 2011 +0900 +++ b/src/myVncClient/WaitReply.java Tue Sep 06 06:23:20 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();