Mercurial > hg > Members > nobuyasu > tightVNCClient
comparison src/myVncClient/MyVncClient.java @ 101:2f2f8da71d60
merge
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 Oct 2011 23:34:32 +0900 |
parents | 1783ca4e4877 084adee7699b |
children | 3599045a7312 |
comparison
equal
deleted
inserted
replaced
100:961a5915834f | 101:2f2f8da71d60 |
---|---|
25 boolean first = true; | 25 boolean first = true; |
26 | 26 |
27 EchoClient echoValue; | 27 EchoClient echoValue; |
28 int echoPort; | 28 int echoPort; |
29 String pHost; | 29 String pHost; |
30 TextBox getHost; | |
30 | 31 |
31 // | 32 // |
32 // main() is called when run as a java program from the command line. | 33 // main() is called when run as a java program from the command line. |
33 // It simply runs the applet inside a newly-created frame. | 34 // It simply runs the applet inside a newly-created frame. |
34 // | 35 // |
41 | 42 |
42 private void runClient(String[] argv) { | 43 private void runClient(String[] argv) { |
43 mainArgs = argv; | 44 mainArgs = argv; |
44 inAnApplet = false; | 45 inAnApplet = false; |
45 inSeparateFrame = true; | 46 inSeparateFrame = true; |
47 getHost = new TextBox(); | |
46 | 48 |
47 if (mainArgs.length > 0) | 49 if (mainArgs.length > 0) |
48 pHost = mainArgs[0]; | 50 pHost = mainArgs[0]; |
49 else | 51 else { |
50 pHost = "cls080.ie.u-ryukyu.ac.jp"; | 52 getHost.ipRegister(); |
53 pHost = getHost.getAddress(); | |
54 } | |
55 | |
56 | |
57 //pHost = "cls080.ie.u-ryukyu.ac.jp"; | |
51 if (mainArgs.length > 1) | 58 if (mainArgs.length > 1) |
52 port = Integer.parseInt(mainArgs[1]); | 59 port = Integer.parseInt(mainArgs[1]); |
53 else | 60 else |
61 | |
54 port = 5999; | 62 port = 5999; |
55 | 63 |
56 init(); | 64 init(); |
57 start_threads(); | 65 start_threads(); |
58 start(); | 66 start(); |
131 accThread.start(); | 139 accThread.start(); |
132 first = false; | 140 first = false; |
133 } else { | 141 } else { |
134 System.out.println("reConnectAndAuthenticate() "); | 142 System.out.println("reConnectAndAuthenticate() "); |
135 reConnectAndAuthenticate(); | 143 reConnectAndAuthenticate(); |
136 accThread = new Thread(new AcceptThread(rfb, 5999)); | 144 //accThread = new Thread(new AcceptThread(rfb, 5999)); |
137 accThread.start(); | 145 //accThread.start(); |
138 } | 146 } |
139 | 147 |
140 doProtocolInitialisation(); | 148 doProtocolInitialisation(); |
141 | 149 |
142 createCanvas(0, 0); | 150 createCanvas(0, 0); |
152 e2.printStackTrace(); | 160 e2.printStackTrace(); |
153 } | 161 } |
154 System.out.println("Socket error"); | 162 System.out.println("Socket error"); |
155 // parent no find | 163 // parent no find |
156 Random rnd = new Random(); | 164 Random rnd = new Random(); |
157 long ran = rnd.nextInt(5000) + 5000; | 165 long ran = rnd.nextInt(3000) + 3000; |
158 System.out.println(ran); | 166 System.out.println(ran); |
159 // 親がいない場合の処理はここに書く!!!! | 167 // 親がいない場合の処理はここに書く!!!! |
160 /** | 168 /** |
161 * this while reconnection | 169 * this while reconnection |
162 */ | 170 */ |
177 Thread.sleep(ran); | 185 Thread.sleep(ran); |
178 } catch (InterruptedException e1) { | 186 } catch (InterruptedException e1) { |
179 e1.printStackTrace(); | 187 e1.printStackTrace(); |
180 } | 188 } |
181 | 189 |
182 if (counter >= 4) { | 190 if (counter >= 6) { |
183 echoValue.openport(); | 191 echoValue.openport(); |
184 echoValue.notfoundParent(); | 192 echoValue.notfoundParent(); |
185 } | 193 } |
186 | 194 |
187 echoValue.openport(); | 195 echoValue.openport(); |
388 if (useEchoPortFlag) { | 396 if (useEchoPortFlag) { |
389 byte[] b = new byte[4]; | 397 byte[] b = new byte[4]; |
390 b = rfb.readEchoPort(); | 398 b = rfb.readEchoPort(); |
391 echoPort = castByteInt(b); | 399 echoPort = castByteInt(b); |
392 | 400 |
401 | |
393 InetAddress addr = InetAddress.getByName(pHost); | 402 InetAddress addr = InetAddress.getByName(pHost); |
394 String h = new String(addr.getHostAddress()); | 403 String h = new String(addr.getHostAddress()); |
395 | 404 |
396 getParentName(); | 405 getParentName(); |
397 if (!(h.equals(host))) { | 406 if (!(h.equals(host))) { |