Mercurial > hg > Members > nobuyasu > tightVNCClient
changeset 35:b3c9be50ef89
add WaitReply
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 08 Jul 2011 20:20:43 +0900 |
parents | 76f5994f2af2 |
children | 451dbe703e39 |
files | src/myVncClient/MyVncClient.java src/myVncClient/echoClient.java src/myVncClient/waitreply.java |
diffstat | 3 files changed, 31 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/src/myVncClient/MyVncClient.java Thu Jul 07 18:12:46 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Fri Jul 08 20:20:43 2011 +0900 @@ -23,13 +23,17 @@ public static void main(String[] argv) { MyVncClient v = new MyVncClient(); - v.mainArgs = argv; - v.inAnApplet = false; - v.inSeparateFrame = true; + v.runClient(argv); + } - v.init(null); - v.start_threads(); - v.start(); + private void runClient(String[] argv) { + mainArgs = argv; + inAnApplet = false; + inSeparateFrame = true; + + init(null); + start_threads(); + start(); } // @@ -647,12 +651,12 @@ } } - // - // readParameters() - read parameters from the html source or from the - // command line. On the command line, the arguments are just a sequence of - // param_name/param_value pairs where the names and values correspond to - // those expected in the html applet tag source. - // + /** + readParameters() - read parameters from the html source or from the + command line. On the command line, the arguments are just a sequence of + param_name/param_value pairs where the names and values correspond to + those expected in the html applet tag source. + */ void readParameters(Revalue value) { /* @@ -668,6 +672,7 @@ if (clientSocket == null) { echo = new echoClient(host); echo.openport(); + value = echo.hostn("1"); } else { echo = new echoClient(); @@ -678,9 +683,9 @@ host = value.responseLine; parent = value.parent; treenum = value.treenum; - System.out.println("親は" + parent); - System.out.println("自分の番号" + treenum); - System.out.println("接続先hostは" + host); + System.out.println("Parent =" + parent); + System.out.println("mynumber =" + treenum); + System.out.println("connect host =" + host); if (host == null) { host = getCodeBase().getHost();
--- a/src/myVncClient/echoClient.java Thu Jul 07 18:12:46 2011 +0900 +++ b/src/myVncClient/echoClient.java Fri Jul 08 20:20:43 2011 +0900 @@ -6,7 +6,7 @@ public class echoClient { public static Revalue value = new Revalue(); - waitreply waitreply;// = new waitreply(); + WaitReply WaitReply;// = new WaitReply(); String responseLine,treenum,parent,line; public static Socket echoSocket = null; BufferedReader lostis = null; @@ -17,9 +17,9 @@ ServerSocket echoServer=null; public static String name; - //waitreplyに自分自身を渡している + //WaitReplyに自分自身を渡している public echoClient(){ - waitreply = new waitreply(this); + WaitReply = new WaitReply(this); } @@ -79,6 +79,10 @@ + /** + * @param args select first connection or other + * @return + */ Revalue hostn(String args){ // サーバーにメッセージを送る if (echoSocket != null && os != null && is != null) { @@ -116,9 +120,9 @@ } - waitreply = new waitreply(this); - System.out.println(waitreply); - waitreply.start(); + WaitReply = new WaitReply(this); + System.out.println(WaitReply); + WaitReply.start(); } return value; @@ -231,7 +235,7 @@ System.out.println(e); } try{ - clientSocket.close();//waitreplyのacceptを終了させる + clientSocket.close();//WaitReplyのacceptを終了させる } catch (IOException e){ System.out.println(e);
--- a/src/myVncClient/waitreply.java Thu Jul 07 18:12:46 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -package myVncClient; - -import java.net.*; -import java.io.*; - - -public class waitreply extends Thread { - echoClient echo; - Socket clientSocket = null; - ServerSocket echoServer=null; - boolean mainFlag; - - waitreply(echoClient _echo){ - echo = _echo; - } - - public void run(){ - - while(true){ - try { - echoServer = new ServerSocket(10001 + Integer.parseInt(echoClient.value.treenum)); - } - catch (IOException e) { - System.out.println(e); - } - try { - clientSocket = echoServer.accept(); - if(clientSocket != null){ - MyVncClient.main(clientSocket); - //echo.Interruption(clientSocket); - } - - }catch (IOException e){ - System.out.println(e); - } - /* - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - */ - } - } -} -