Mercurial > hg > Members > nobuyasu > tightVNCClient
annotate src/myVncClient/MyVncClient.java @ 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 | 6c43d40abfe6 |
rev | line source |
---|---|
20 | 1 package myVncClient; |
2 | |
3 import java.awt.*; | |
4 import java.awt.event.*; | |
5 import java.io.*; | |
6 import java.net.*; | |
41 | 7 import java.util.Random; |
20 | 8 |
73 | 9 import java.nio.ByteBuffer; |
10 | |
60 | 11 public class MyVncClient extends VncViewer implements InterfaceForViewer, java.lang.Runnable, |
32 | 12 WindowListener { |
20 | 13 |
50
c07bec8c8617
change echoClient.java EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
14 /** |
71 | 15 * |
50
c07bec8c8617
change echoClient.java EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
16 */ |
c07bec8c8617
change echoClient.java EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
17 private static final long serialVersionUID = 1L; |
20 | 18 boolean inAnApplet = true; |
19 boolean inSeparateFrame = false; | |
50
c07bec8c8617
change echoClient.java EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
20 Socket clientSocket = null; |
32 | 21 String parent, treenum; |
50
c07bec8c8617
change echoClient.java EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
22 private String leaderflag; |
55
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
23 boolean runflag = false; |
69 | 24 boolean first = true; |
74 | 25 |
79 | 26 EchoClient echoValue; |
27 int echoPort; | |
28 String pHost; | |
29 | |
20 | 30 // |
31 // main() is called when run as a java program from the command line. | |
32 // It simply runs the applet inside a newly-created frame. | |
33 // | |
34 | |
60 | 35 public static void main(String[] argv) { |
51 | 36 MyVncClient v = new MyVncClient(); |
79 | 37 v.echoValue = null; |
51 | 38 v.runClient(argv); |
39 } | |
20 | 40 |
51 | 41 private void runClient(String[] argv) { |
42 mainArgs = argv; | |
35 | 43 inAnApplet = false; |
44 inSeparateFrame = true; | |
45 | |
76 | 46 if (mainArgs.length > 0) |
79 | 47 pHost = mainArgs[0]; |
76 | 48 else |
79 | 49 pHost = "cls080.ie.u-ryukyu.ac.jp"; |
76 | 50 if (mainArgs.length > 1) |
51 port = Integer.parseInt(mainArgs[1]); | |
52 else | |
53 port = 5999; | |
73 | 54 |
74 | 55 init(); |
35 | 56 start_threads(); |
57 start(); | |
20 | 58 } |
59 | |
60 // | |
61 // init() | |
62 // | |
63 | |
74 | 64 public void init() { |
60 | 65 |
73 | 66 readParameters(); |
20 | 67 |
68 refApplet = this; | |
69 | |
70 if (inSeparateFrame) { | |
71 vncFrame = new Frame("TightVNC"); | |
72 if (!inAnApplet) { | |
73 vncFrame.add("Center", this); | |
74 } | |
75 vncContainer = vncFrame; | |
76 } else { | |
77 vncContainer = this; | |
78 } | |
79 | |
80 recordingSync = new Object(); | |
81 | |
82 options = new OptionsFrame(this); | |
83 clipboard = new ClipboardFrame(this); | |
84 if (RecordingFrame.checkSecurity()) | |
85 rec = new RecordingFrame(this); | |
86 | |
87 sessionFileName = null; | |
88 recordingActive = false; | |
89 recordingStatusChanged = false; | |
90 cursorUpdatesDef = null; | |
91 eightBitColorsDef = null; | |
92 | |
93 if (inSeparateFrame) | |
94 vncFrame.addWindowListener(this); | |
95 | |
96 rfbThread = new Thread(this); | |
97 } | |
98 | |
99 public void update(Graphics g) { | |
100 } | |
101 | |
102 // | |
103 // run() - executed by the rfbThread to deal with the RFB socket. | |
104 // | |
105 | |
60 | 106 public void start_threads() { |
33 | 107 rfbThread.start(); |
108 } | |
60 | 109 |
110 public void run() { | |
72 | 111 |
20 | 112 gridbag = new GridBagLayout(); |
113 vncContainer.setLayout(gridbag); | |
114 | |
115 GridBagConstraints gbc = new GridBagConstraints(); | |
116 gbc.gridwidth = GridBagConstraints.REMAINDER; | |
117 gbc.anchor = GridBagConstraints.NORTHWEST; | |
118 | |
119 if (showControls) { | |
120 buttonPanel = new ButtonPanel(this); | |
121 gridbag.setConstraints(buttonPanel, gbc); | |
122 vncContainer.add(buttonPanel); | |
123 } | |
60 | 124 |
20 | 125 try { |
126 | |
69 | 127 if (first) { |
71 | 128 connectAndAuthenticate(); |
70 | 129 accThread = new Thread(new AcceptThread(rfb, 5999)); |
130 accThread.start(); | |
69 | 131 first = false; |
132 }else { | |
70 | 133 System.out.println("reConnectAndAuthenticate() "); |
69 | 134 reConnectAndAuthenticate(); |
84 | 135 accThread = new Thread(new AcceptThread(rfb, 5999)); |
136 accThread.start(); | |
69 | 137 } |
32 | 138 |
27 | 139 doProtocolInitialisation(); |
140 | |
20 | 141 createCanvas(0, 0); |
26 | 142 |
32 | 143 // rfb.readPngData(); |
144 // vc.drawFirstImage(); | |
20 | 145 |
146 } catch (IOException e) { | |
70 | 147 try{ |
148 rfb.sock.close(); | |
149 | |
150 }catch(IOException e2){ | |
151 e2.printStackTrace(); | |
152 } | |
20 | 153 System.out.println("Socket error"); |
41 | 154 // parent no find |
155 Random rnd = new Random(); | |
48
67655ba93e92
reconnection at connecton faild
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
46
diff
changeset
|
156 long ran = rnd.nextInt(5000) + 5000; |
67655ba93e92
reconnection at connecton faild
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
46
diff
changeset
|
157 System.out.println(ran); |
60 | 158 // 親がいない場合の処理はここに書く!!!! |
52 | 159 /** |
60 | 160 * this while reconnection |
52 | 161 */ |
60 | 162 |
55
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
163 int counter = 0; |
69 | 164 vncFrame.setVisible(false); |
165 vncFrame.dispose(); | |
166 | |
41 | 167 while (true) { |
52 | 168 /** |
60 | 169 * if my last node case reconnectoion stop |
52 | 170 */ |
60 | 171 |
79 | 172 echoValue = new EchoClient(echoValue, this); |
41 | 173 try { |
174 Thread.sleep(ran); | |
60 | 175 } catch (InterruptedException e1) { |
41 | 176 e1.printStackTrace(); |
177 } | |
60 | 178 |
179 if (counter >= 3) { | |
79 | 180 echoValue.openport(); |
181 echoValue.notfoundParent(); | |
55
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
182 } |
60 | 183 |
79 | 184 echoValue.openport(); |
60 | 185 // runflag = echo.losthost(); |
79 | 186 if (echoValue.losthost()) { |
52 | 187 break; |
188 } | |
55
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
189 counter++; |
41 | 190 } |
69 | 191 |
41 | 192 // System.exit(0); |
32 | 193 } catch (Exception e) { |
33 | 194 System.out.println(e); |
41 | 195 System.exit(0); |
20 | 196 } |
197 | |
198 gbc.weightx = 1.0; | |
199 gbc.weighty = 1.0; | |
200 | |
32 | 201 if (inSeparateFrame) { |
20 | 202 |
203 // Create a panel which itself is resizeable and can hold | |
204 // non-resizeable VncCanvas component at the top left corner. | |
205 Panel canvasPanel = new Panel(); | |
206 canvasPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); | |
207 canvasPanel.add(vc); | |
208 | |
209 // Create a ScrollPane which will hold a panel with VncCanvas | |
210 // inside. | |
211 desktopScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); | |
212 gbc.fill = GridBagConstraints.BOTH; | |
213 gridbag.setConstraints(desktopScrollPane, gbc); | |
214 desktopScrollPane.add(canvasPanel); | |
215 | |
216 // Finally, add our ScrollPane to the Frame window. | |
217 vncFrame.add(desktopScrollPane); | |
218 vncFrame.setTitle(rfb.desktopName); | |
219 vncFrame.pack(); | |
220 vc.resizeDesktopFrame(); | |
221 | |
222 } else { | |
223 | |
224 // Just add the VncCanvas component to the Applet. | |
225 gridbag.setConstraints(vc, gbc); | |
226 add(vc); | |
227 validate(); | |
228 | |
229 } | |
230 | |
231 try { | |
232 if (showControls) | |
233 buttonPanel.enableButtons(); | |
234 | |
235 moveFocusToDesktop(); | |
236 | |
237 processNormalProtocol();// main loop | |
238 | |
239 } catch (NoRouteToHostException e) { | |
240 fatalError("Network error: no route to server: " + host, e); | |
241 } catch (UnknownHostException e) { | |
242 fatalError("Network error: server name unknown: " + host, e); | |
243 } catch (ConnectException e) { | |
244 fatalError("Network error: could not connect to server: " + host | |
245 + ":" + port, e); | |
246 } catch (EOFException e) { | |
70 | 247 |
34 | 248 vncFrame.setVisible(false); |
65 | 249 vncFrame.dispose(); |
60 | 250 // num4 |
80 | 251 if ( leaderflag != null) { |
60 | 252 while (true) { |
79 | 253 echoValue = new EchoClient(echoValue, this); |
254 echoValue.openport(); | |
60 | 255 // runflag = echo.losthost(); |
79 | 256 if (echoValue.losthost()) { |
55
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
257 break; |
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
258 } |
f2f4b0398f04
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
52
diff
changeset
|
259 } |
32 | 260 } else { |
29
750ecaa1e1b9
add echoClient.java and waitreply.java. modify MyRfbProto.java
e085711
parents:
27
diff
changeset
|
261 |
32 | 262 if (showOfflineDesktop) { |
263 e.printStackTrace(); | |
264 System.out | |
265 .println("Network error: remote side closed connection"); | |
266 if (vc != null) { | |
267 vc.enableInput(false); | |
268 } | |
269 if (inSeparateFrame) { | |
270 vncFrame.setTitle(rfb.desktopName + " [disconnected]"); | |
271 } | |
272 if (rfb != null && !rfb.closed()) | |
273 rfb.close(); | |
274 if (showControls && buttonPanel != null) { | |
275 buttonPanel.disableButtonsOnDisconnect(); | |
276 if (inSeparateFrame) { | |
277 vncFrame.pack(); | |
278 } else { | |
279 validate(); | |
280 } | |
281 } | |
282 } else { | |
283 fatalError("Network error: remote side closed connection", | |
284 e); | |
20 | 285 } |
286 } | |
287 } catch (IOException e) { | |
288 String str = e.getMessage(); | |
289 if (str != null && str.length() != 0) { | |
290 fatalError("Network Error: " + str, e); | |
291 } else { | |
292 fatalError(e.toString(), e); | |
293 } | |
294 } catch (Exception e) { | |
295 String str = e.getMessage(); | |
296 if (str != null && str.length() != 0) { | |
297 fatalError("Error: " + str, e); | |
298 } else { | |
299 fatalError(e.toString(), e); | |
300 } | |
301 } | |
302 | |
303 } | |
304 | |
305 // | |
306 // Create a VncCanvas instance. | |
307 // | |
308 | |
309 void createCanvas(int maxWidth, int maxHeight) throws IOException { | |
310 // Determine if Java 2D API is available and use a special | |
311 // version of VncCanvas if it is present. | |
312 vc = null; | |
313 try { | |
314 // This throws ClassNotFoundException if there is no Java 2D API. | |
315 Class cl = Class.forName("java.awt.Graphics2D"); | |
316 // If we could load Graphics2D class, then we can use VncCanvas2D. | |
317 cl = Class.forName("VncCanvas2"); | |
318 Class[] argClasses = { this.getClass(), Integer.TYPE, Integer.TYPE }; | |
319 java.lang.reflect.Constructor cstr = cl.getConstructor(argClasses); | |
320 Object[] argObjects = { this, new Integer(maxWidth), | |
321 new Integer(maxHeight) }; | |
322 vc = (VncCanvas) cstr.newInstance(argObjects); | |
323 } catch (Exception e) { | |
324 System.out.println("Warning: Java 2D API is not available"); | |
325 } | |
326 | |
327 // If we failed to create VncCanvas2D, use old VncCanvas. | |
328 if (vc == null) | |
329 vc = new VncCanvas(this, maxWidth, maxHeight); | |
330 } | |
331 | |
332 // | |
333 // Process RFB socket messages. | |
334 // If the rfbThread is being stopped, ignore any exceptions, | |
335 // otherwise rethrow the exception so it can be handled. | |
336 // | |
337 | |
338 void processNormalProtocol() throws Exception { | |
339 try { | |
340 vc.processNormalProtocol();// main loop | |
341 } catch (Exception e) { | |
342 if (rfbThread == null) { | |
343 System.out.println("Ignoring RFB socket exceptions" | |
344 + " because applet is stopping"); | |
345 } else { | |
346 throw e; | |
347 } | |
348 } | |
349 } | |
350 | |
351 // | |
352 // Connect to the RFB server and authenticate the user. | |
353 // | |
354 | |
355 void connectAndAuthenticate() throws Exception { | |
27 | 356 |
20 | 357 showConnectionStatus("Initializing..."); |
358 if (inSeparateFrame) { | |
359 vncFrame.pack(); | |
360 vncFrame.setVisible(true); | |
361 } else { | |
362 validate(); | |
363 } | |
364 | |
365 showConnectionStatus("Connecting to " + host + ", port " + port + "..."); | |
366 | |
79 | 367 rfb = new MyRfbProto(pHost, port, this); |
20 | 368 showConnectionStatus("Connected to server"); |
369 | |
370 rfb.readVersionMsg(); | |
371 showConnectionStatus("RFB server supports protocol version " | |
372 + rfb.serverMajor + "." + rfb.serverMinor); | |
373 | |
73 | 374 rfb.writeVersionMsg(); |
375 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor | |
376 + "." + rfb.clientMinor); | |
377 | |
79 | 378 |
72 | 379 if(rfb.serverMinor == 998) { |
73 | 380 byte[] b = new byte[4]; |
381 b = rfb.readEchoPort(); | |
79 | 382 echoPort = castByteInt(b); |
76 | 383 |
79 | 384 InetAddress addr = InetAddress.getByName(pHost); |
76 | 385 String h = new String(addr.getHostAddress()); |
386 | |
79 | 387 getParentName(); |
76 | 388 if(!(h.equals(host))) { |
72 | 389 rfb.changeParent(host, port); |
390 rfb.readVersionMsg(); | |
76 | 391 rfb.writeVersionMsg(); |
72 | 392 } |
393 } | |
79 | 394 |
72 | 395 |
20 | 396 int secType = rfb.negotiateSecurity(); |
397 int authType; | |
398 if (secType == RfbProto.SecTypeTight) { | |
399 showConnectionStatus("Enabling TightVNC protocol extensions"); | |
400 rfb.setupTunneling(); | |
401 authType = rfb.negotiateAuthenticationTight(); | |
402 } else { | |
403 authType = secType; | |
404 } | |
405 | |
406 switch (authType) { | |
407 case RfbProto.AuthNone: | |
408 showConnectionStatus("No authentication needed"); | |
409 rfb.authenticateNone(); | |
410 break; | |
411 case RfbProto.AuthVNC: | |
412 showConnectionStatus("Performing standard VNC authentication"); | |
413 if (passwordParam != null) { | |
414 rfb.authenticateVNC(passwordParam); | |
415 } else { | |
416 String pw = askPassword(); | |
417 rfb.authenticateVNC(pw); | |
418 } | |
419 break; | |
420 default: | |
421 throw new Exception("Unknown authentication scheme " + authType); | |
422 } | |
423 } | |
424 | |
69 | 425 void reConnectAndAuthenticate() throws Exception { |
71 | 426 |
69 | 427 showConnectionStatus("Initializing..."); |
428 | |
71 | 429 if (inSeparateFrame) { |
430 vncFrame.pack(); | |
431 vncFrame.setVisible(true); | |
432 } else { | |
433 validate(); | |
434 } | |
435 | |
69 | 436 showConnectionStatus("Connecting to " + host + ", port " + port + "..."); |
437 | |
438 rfb.changeParent(host, port); | |
439 | |
440 showConnectionStatus("Connected to server"); | |
441 | |
442 rfb.readVersionMsg(); | |
443 showConnectionStatus("RFB server supports protocol version " | |
444 + rfb.serverMajor + "." + rfb.serverMinor); | |
445 | |
446 rfb.writeVersionMsg(); | |
447 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor | |
448 + "." + rfb.clientMinor); | |
449 | |
77 | 450 |
451 if(rfb.serverMinor == 998) { | |
452 byte[] b = new byte[4]; | |
453 b = rfb.readEchoPort(); | |
454 int echoPort = castByteInt(b); | |
455 | |
456 InetAddress addr = InetAddress.getByName(host); | |
457 String h = new String(addr.getHostAddress()); | |
458 | |
79 | 459 getParentName(); |
77 | 460 if(!(h.equals(host))) { |
461 rfb.changeParent(host, port); | |
462 rfb.readVersionMsg(); | |
463 rfb.writeVersionMsg(); | |
464 } | |
465 } | |
466 | |
467 | |
69 | 468 int secType = rfb.negotiateSecurity(); |
469 int authType; | |
470 if (secType == RfbProto.SecTypeTight) { | |
471 showConnectionStatus("Enabling TightVNC protocol extensions"); | |
472 rfb.setupTunneling(); | |
473 authType = rfb.negotiateAuthenticationTight(); | |
474 } else { | |
475 authType = secType; | |
476 } | |
477 | |
478 switch (authType) { | |
479 case RfbProto.AuthNone: | |
480 showConnectionStatus("No authentication needed"); | |
481 rfb.authenticateNone(); | |
482 break; | |
483 case RfbProto.AuthVNC: | |
484 showConnectionStatus("Performing standard VNC authentication"); | |
485 if (passwordParam != null) { | |
486 rfb.authenticateVNC(passwordParam); | |
487 } else { | |
488 String pw = askPassword(); | |
489 rfb.authenticateVNC(pw); | |
490 } | |
491 break; | |
492 default: | |
493 throw new Exception("Unknown authentication scheme " + authType); | |
494 } | |
495 } | |
20 | 496 // |
497 // Show a message describing the connection status. | |
498 // To hide the connection status label, use (msg == null). | |
499 // | |
500 | |
501 void showConnectionStatus(String msg) { | |
502 if (msg == null) { | |
503 if (vncContainer.isAncestorOf(connStatusLabel)) { | |
504 vncContainer.remove(connStatusLabel); | |
505 } | |
506 return; | |
507 } | |
508 | |
509 System.out.println(msg); | |
510 | |
511 if (connStatusLabel == null) { | |
512 connStatusLabel = new Label("Status: " + msg); | |
513 connStatusLabel.setFont(new Font("Helvetica", Font.PLAIN, 12)); | |
514 } else { | |
515 connStatusLabel.setText("Status: " + msg); | |
516 } | |
517 | |
518 if (!vncContainer.isAncestorOf(connStatusLabel)) { | |
519 GridBagConstraints gbc = new GridBagConstraints(); | |
520 gbc.gridwidth = GridBagConstraints.REMAINDER; | |
521 gbc.fill = GridBagConstraints.HORIZONTAL; | |
522 gbc.anchor = GridBagConstraints.NORTHWEST; | |
523 gbc.weightx = 1.0; | |
524 gbc.weighty = 1.0; | |
525 gbc.insets = new Insets(20, 30, 20, 30); | |
526 gridbag.setConstraints(connStatusLabel, gbc); | |
527 vncContainer.add(connStatusLabel); | |
528 } | |
529 | |
530 if (inSeparateFrame) { | |
531 vncFrame.pack(); | |
532 } else { | |
533 validate(); | |
534 } | |
535 } | |
536 | |
537 // | |
538 // Show an authentication panel. | |
539 // | |
540 | |
541 String askPassword() throws Exception { | |
542 showConnectionStatus(null); | |
543 | |
544 AuthPanel authPanel = new AuthPanel(this); | |
545 | |
546 GridBagConstraints gbc = new GridBagConstraints(); | |
547 gbc.gridwidth = GridBagConstraints.REMAINDER; | |
548 gbc.anchor = GridBagConstraints.NORTHWEST; | |
549 gbc.weightx = 1.0; | |
550 gbc.weighty = 1.0; | |
551 gbc.ipadx = 100; | |
552 gbc.ipady = 50; | |
553 gridbag.setConstraints(authPanel, gbc); | |
554 vncContainer.add(authPanel); | |
555 | |
556 if (inSeparateFrame) { | |
557 vncFrame.pack(); | |
558 } else { | |
559 validate(); | |
560 } | |
561 | |
562 authPanel.moveFocusToDefaultField(); | |
563 String pw = authPanel.getPassword(); | |
564 vncContainer.remove(authPanel); | |
565 return pw; | |
566 } | |
567 | |
568 // | |
569 // Do the rest of the protocol initialisation. | |
570 // | |
571 | |
572 void doProtocolInitialisation() throws IOException { | |
573 rfb.writeClientInit(); | |
574 rfb.readServerInit(); | |
575 | |
576 System.out.println("Desktop name is " + rfb.desktopName); | |
577 System.out.println("Desktop size is " + rfb.framebufferWidth + " x " | |
578 + rfb.framebufferHeight); | |
579 | |
580 setEncodings(); | |
581 | |
582 showConnectionStatus(null); | |
583 } | |
584 | |
585 // | |
586 // Send current encoding list to the RFB server. | |
587 // | |
588 | |
589 int[] encodingsSaved; | |
590 int nEncodingsSaved; | |
591 | |
592 void setEncodings() { | |
593 setEncodings(false); | |
594 } | |
595 | |
596 void autoSelectEncodings() { | |
597 setEncodings(true); | |
598 } | |
599 | |
600 void setEncodings(boolean autoSelectOnly) { | |
601 if (options == null || rfb == null || !rfb.inNormalProtocol) | |
602 return; | |
603 | |
604 int preferredEncoding = options.preferredEncoding; | |
605 if (preferredEncoding == -1) { | |
606 long kbitsPerSecond = rfb.kbitsPerSecond(); | |
607 if (nEncodingsSaved < 1) { | |
608 // Choose Tight or ZRLE encoding for the very first update. | |
609 System.out.println("Using Tight/ZRLE encodings"); | |
610 preferredEncoding = RfbProto.EncodingTight; | |
611 } else if (kbitsPerSecond > 2000 | |
612 && encodingsSaved[0] != RfbProto.EncodingHextile) { | |
613 // Switch to Hextile if the connection speed is above 2Mbps. | |
614 System.out.println("Throughput " + kbitsPerSecond | |
615 + " kbit/s - changing to Hextile encoding"); | |
616 preferredEncoding = RfbProto.EncodingHextile; | |
617 } else if (kbitsPerSecond < 1000 | |
618 && encodingsSaved[0] != RfbProto.EncodingTight) { | |
619 // Switch to Tight/ZRLE if the connection speed is below 1Mbps. | |
620 System.out.println("Throughput " + kbitsPerSecond | |
621 + " kbit/s - changing to Tight/ZRLE encodings"); | |
622 preferredEncoding = RfbProto.EncodingTight; | |
623 } else { | |
624 // Don't change the encoder. | |
625 if (autoSelectOnly) | |
626 return; | |
627 preferredEncoding = encodingsSaved[0]; | |
628 } | |
629 } else { | |
630 // Auto encoder selection is not enabled. | |
631 if (autoSelectOnly) | |
632 return; | |
633 } | |
634 | |
635 int[] encodings = new int[20]; | |
636 int nEncodings = 0; | |
637 | |
638 encodings[nEncodings++] = preferredEncoding; | |
639 if (options.useCopyRect) { | |
640 encodings[nEncodings++] = RfbProto.EncodingCopyRect; | |
641 } | |
642 | |
643 if (preferredEncoding != RfbProto.EncodingTight) { | |
644 encodings[nEncodings++] = RfbProto.EncodingTight; | |
645 } | |
646 if (preferredEncoding != RfbProto.EncodingZRLE) { | |
647 encodings[nEncodings++] = RfbProto.EncodingZRLE; | |
648 } | |
649 if (preferredEncoding != RfbProto.EncodingHextile) { | |
650 encodings[nEncodings++] = RfbProto.EncodingHextile; | |
651 } | |
652 if (preferredEncoding != RfbProto.EncodingZlib) { | |
653 encodings[nEncodings++] = RfbProto.EncodingZlib; | |
654 } | |
655 if (preferredEncoding != RfbProto.EncodingCoRRE) { | |
656 encodings[nEncodings++] = RfbProto.EncodingCoRRE; | |
657 } | |
658 if (preferredEncoding != RfbProto.EncodingRRE) { | |
659 encodings[nEncodings++] = RfbProto.EncodingRRE; | |
660 } | |
661 | |
662 if (options.compressLevel >= 0 && options.compressLevel <= 9) { | |
663 encodings[nEncodings++] = RfbProto.EncodingCompressLevel0 | |
664 + options.compressLevel; | |
665 } | |
666 if (options.jpegQuality >= 0 && options.jpegQuality <= 9) { | |
667 encodings[nEncodings++] = RfbProto.EncodingQualityLevel0 | |
668 + options.jpegQuality; | |
669 } | |
670 | |
671 if (options.requestCursorUpdates) { | |
672 encodings[nEncodings++] = RfbProto.EncodingXCursor; | |
673 encodings[nEncodings++] = RfbProto.EncodingRichCursor; | |
674 if (!options.ignoreCursorUpdates) | |
675 encodings[nEncodings++] = RfbProto.EncodingPointerPos; | |
676 } | |
677 | |
678 encodings[nEncodings++] = RfbProto.EncodingLastRect; | |
679 encodings[nEncodings++] = RfbProto.EncodingNewFBSize; | |
680 | |
681 boolean encodingsWereChanged = false; | |
682 if (nEncodings != nEncodingsSaved) { | |
683 encodingsWereChanged = true; | |
684 } else { | |
685 for (int i = 0; i < nEncodings; i++) { | |
686 if (encodings[i] != encodingsSaved[i]) { | |
687 encodingsWereChanged = true; | |
688 break; | |
689 } | |
690 } | |
691 } | |
692 | |
693 if (encodingsWereChanged) { | |
694 try { | |
695 rfb.writeSetEncodings(encodings, nEncodings); | |
696 if (vc != null) { | |
697 vc.softCursorFree(); | |
698 } | |
699 } catch (Exception e) { | |
700 e.printStackTrace(); | |
701 } | |
702 encodingsSaved = encodings; | |
703 nEncodingsSaved = nEncodings; | |
704 } | |
705 } | |
706 | |
707 // | |
708 // setCutText() - send the given cut text to the RFB server. | |
709 // | |
710 | |
711 void setCutText(String text) { | |
712 try { | |
713 if (rfb != null && rfb.inNormalProtocol) { | |
714 rfb.writeClientCutText(text); | |
715 } | |
716 } catch (Exception e) { | |
717 e.printStackTrace(); | |
718 } | |
719 } | |
720 | |
721 // | |
722 // Order change in session recording status. To stop recording, pass | |
723 // null in place of the fname argument. | |
724 // | |
725 | |
726 void setRecordingStatus(String fname) { | |
727 synchronized (recordingSync) { | |
728 sessionFileName = fname; | |
729 recordingStatusChanged = true; | |
730 } | |
731 } | |
732 | |
733 // | |
734 // Start or stop session recording. Returns true if this method call | |
735 // causes recording of a new session. | |
736 // | |
737 | |
738 boolean checkRecordingStatus() throws IOException { | |
739 synchronized (recordingSync) { | |
740 if (recordingStatusChanged) { | |
741 recordingStatusChanged = false; | |
742 if (sessionFileName != null) { | |
743 startRecording(); | |
744 return true; | |
745 } else { | |
746 stopRecording(); | |
747 } | |
748 } | |
749 } | |
750 return false; | |
751 } | |
752 | |
753 // | |
754 // Start session recording. | |
755 // | |
756 | |
757 protected void startRecording() throws IOException { | |
758 synchronized (recordingSync) { | |
759 if (!recordingActive) { | |
760 // Save settings to restore them after recording the session. | |
761 cursorUpdatesDef = options.choices[options.cursorUpdatesIndex] | |
762 .getSelectedItem(); | |
763 eightBitColorsDef = options.choices[options.eightBitColorsIndex] | |
764 .getSelectedItem(); | |
765 // Set options to values suitable for recording. | |
766 options.choices[options.cursorUpdatesIndex].select("Disable"); | |
767 options.choices[options.cursorUpdatesIndex].setEnabled(false); | |
768 options.setEncodings(); | |
769 options.choices[options.eightBitColorsIndex].select("No"); | |
770 options.choices[options.eightBitColorsIndex].setEnabled(false); | |
771 options.setColorFormat(); | |
772 } else { | |
773 rfb.closeSession(); | |
774 } | |
775 | |
776 System.out.println("Recording the session in " + sessionFileName); | |
777 rfb.startSession(sessionFileName); | |
778 recordingActive = true; | |
779 } | |
780 } | |
781 | |
782 // | |
783 // Stop session recording. | |
784 // | |
785 | |
786 protected void stopRecording() throws IOException { | |
787 synchronized (recordingSync) { | |
788 if (recordingActive) { | |
789 // Restore options. | |
790 options.choices[options.cursorUpdatesIndex] | |
791 .select(cursorUpdatesDef); | |
792 options.choices[options.cursorUpdatesIndex].setEnabled(true); | |
793 options.setEncodings(); | |
794 options.choices[options.eightBitColorsIndex] | |
795 .select(eightBitColorsDef); | |
796 options.choices[options.eightBitColorsIndex].setEnabled(true); | |
797 options.setColorFormat(); | |
798 | |
799 rfb.closeSession(); | |
800 System.out.println("Session recording stopped."); | |
801 } | |
802 sessionFileName = null; | |
803 recordingActive = false; | |
804 } | |
805 } | |
806 | |
35 | 807 /** |
60 | 808 * readParameters() - read parameters from the html source or from the |
809 * command line. On the command line, the arguments are just a sequence of | |
810 * param_name/param_value pairs where the names and values correspond to | |
811 * those expected in the html applet tag source. | |
812 */ | |
20 | 813 |
73 | 814 void readParameters() { |
32 | 815 /* |
816 * host = readParameter("HOST", !inAnApplet); | |
817 * | |
818 * if (host == null) { host = getCodeBase().getHost(); if | |
819 * (host.equals("")) { fatalError("HOST parameter not specified"); } } | |
820 * | |
821 * port = readIntParameter("PORT", 5550); | |
822 */ | |
72 | 823 |
30 | 824 // Read "ENCPASSWORD" or "PASSWORD" parameter if specified. |
20 | 825 readPasswordParameters(); |
826 | |
827 String str; | |
828 if (inAnApplet) { | |
829 str = readParameter("Open New Window", false); | |
830 if (str != null && str.equalsIgnoreCase("Yes")) | |
831 inSeparateFrame = true; | |
832 } | |
833 | |
834 // "Show Controls" set to "No" disables button panel. | |
835 showControls = true; | |
836 str = readParameter("Show Controls", false); | |
837 if (str != null && str.equalsIgnoreCase("No")) | |
838 showControls = false; | |
839 | |
840 // "Offer Relogin" set to "No" disables "Login again" and "Close | |
841 // window" buttons under error messages in applet mode. | |
842 offerRelogin = true; | |
843 str = readParameter("Offer Relogin", false); | |
844 if (str != null && str.equalsIgnoreCase("No")) | |
845 offerRelogin = false; | |
846 | |
847 // Do we continue showing desktop on remote disconnect? | |
848 showOfflineDesktop = false; | |
849 str = readParameter("Show Offline Desktop", false); | |
850 if (str != null && str.equalsIgnoreCase("Yes")) | |
851 showOfflineDesktop = true; | |
852 | |
853 // Fine tuning options. | |
854 deferScreenUpdates = readIntParameter("Defer screen updates", 20); | |
855 deferCursorUpdates = readIntParameter("Defer cursor updates", 10); | |
856 deferUpdateRequests = readIntParameter("Defer update requests", 0); | |
857 | |
858 // Debugging options. | |
859 debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0); | |
860 debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0); | |
861 | |
862 // SocketFactory. | |
863 socketFactory = readParameter("SocketFactory", false); | |
864 } | |
865 | |
866 // | |
867 // Read password parameters. If an "ENCPASSWORD" parameter is set, | |
868 // then decrypt the password into the passwordParam string. Otherwise, | |
869 // try to read the "PASSWORD" parameter directly to passwordParam. | |
870 // | |
871 | |
872 private void readPasswordParameters() { | |
873 String encPasswordParam = readParameter("ENCPASSWORD", false); | |
874 if (encPasswordParam == null) { | |
875 passwordParam = readParameter("PASSWORD", false); | |
876 | |
877 } else { | |
878 // ENCPASSWORD is hexascii-encoded. Decode. | |
879 byte[] pw = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |
880 int len = encPasswordParam.length() / 2; | |
881 if (len > 8) | |
882 len = 8; | |
883 for (int i = 0; i < len; i++) { | |
884 String hex = encPasswordParam.substring(i * 2, i * 2 + 2); | |
885 Integer x = new Integer(Integer.parseInt(hex, 16)); | |
886 pw[i] = x.byteValue(); | |
887 } | |
888 // Decrypt the password. | |
889 byte[] key = { 23, 82, 107, 6, 35, 78, 88, 7 }; | |
890 DesCipher des = new DesCipher(key); | |
891 des.decrypt(pw, 0, pw, 0); | |
892 passwordParam = new String(pw); | |
893 | |
894 } | |
895 } | |
896 | |
897 public String readParameter(String name, boolean required) { | |
898 if (inAnApplet) { | |
899 String s = getParameter(name); | |
900 if ((s == null) && required) { | |
901 fatalError(name + " parameter not specified"); | |
902 } | |
903 return s; | |
904 } | |
60 | 905 /* |
906 * for (int i = 0; i < mainArgs.length; i += 2) { if | |
907 * (mainArgs[i].equalsIgnoreCase(name)) { try { return mainArgs[i + 1]; | |
908 * } catch (Exception e) { if (required) { fatalError(name + | |
909 * " parameter not specified"); } return null; } } } | |
910 */ | |
20 | 911 if (required) { |
912 fatalError(name + " parameter not specified"); | |
913 } | |
914 return null; | |
915 } | |
916 | |
917 int readIntParameter(String name, int defaultValue) { | |
918 String str = readParameter(name, false); | |
919 int result = defaultValue; | |
920 if (str != null) { | |
921 try { | |
922 result = Integer.parseInt(str); | |
923 } catch (NumberFormatException e) { | |
924 } | |
925 } | |
926 return result; | |
927 } | |
928 | |
929 // | |
930 // moveFocusToDesktop() - move keyboard focus either to VncCanvas. | |
931 // | |
932 | |
933 void moveFocusToDesktop() { | |
934 if (vncContainer != null) { | |
935 if (vc != null && vncContainer.isAncestorOf(vc)) | |
936 vc.requestFocus(); | |
937 } | |
938 } | |
939 | |
940 // | |
941 // disconnect() - close connection to server. | |
942 // | |
943 | |
944 synchronized public void disconnect() { | |
945 System.out.println("Disconnecting"); | |
946 | |
947 if (vc != null) { | |
948 double sec = (System.currentTimeMillis() - vc.statStartTime) / 1000.0; | |
949 double rate = Math.round(vc.statNumUpdates / sec * 100) / 100.0; | |
950 int nRealRects = vc.statNumPixelRects; | |
951 int nPseudoRects = vc.statNumTotalRects - vc.statNumPixelRects; | |
952 System.out.println("Updates received: " + vc.statNumUpdates + " (" | |
953 + nRealRects + " rectangles + " + nPseudoRects | |
954 + " pseudo), " + rate + " updates/sec"); | |
955 int numRectsOther = nRealRects - vc.statNumRectsTight | |
956 - vc.statNumRectsZRLE - vc.statNumRectsHextile | |
957 - vc.statNumRectsRaw - vc.statNumRectsCopy; | |
958 System.out.println("Rectangles:" + " Tight=" + vc.statNumRectsTight | |
959 + "(JPEG=" + vc.statNumRectsTightJPEG + ") ZRLE=" | |
960 + vc.statNumRectsZRLE + " Hextile=" | |
961 + vc.statNumRectsHextile + " Raw=" + vc.statNumRectsRaw | |
962 + " CopyRect=" + vc.statNumRectsCopy + " other=" | |
963 + numRectsOther); | |
964 | |
965 int raw = vc.statNumBytesDecoded; | |
966 int compressed = vc.statNumBytesEncoded; | |
967 if (compressed > 0) { | |
968 double ratio = Math.round((double) raw / compressed * 1000) / 1000.0; | |
969 System.out.println("Pixel data: " + vc.statNumBytesDecoded | |
970 + " bytes, " + vc.statNumBytesEncoded | |
971 + " compressed, ratio " + ratio); | |
972 } | |
973 } | |
974 | |
975 if (rfb != null && !rfb.closed()) | |
976 rfb.close(); | |
977 options.dispose(); | |
978 clipboard.dispose(); | |
979 if (rec != null) | |
980 rec.dispose(); | |
981 | |
982 if (inAnApplet) { | |
983 showMessage("Disconnected"); | |
984 } else { | |
985 System.exit(0); | |
986 } | |
987 } | |
988 | |
989 // | |
990 // fatalError() - print out a fatal error message. | |
991 // FIXME: Do we really need two versions of the fatalError() method? | |
992 // | |
993 | |
994 synchronized public void fatalError(String str) { | |
995 System.out.println(str); | |
996 | |
997 if (inAnApplet) { | |
998 // vncContainer null, applet not inited, | |
999 // can not present the error to the user. | |
1000 Thread.currentThread().stop(); | |
1001 } else { | |
1002 System.exit(1); | |
1003 } | |
1004 } | |
1005 | |
1006 synchronized public void fatalError(String str, Exception e) { | |
1007 | |
1008 if (rfb != null && rfb.closed()) { | |
1009 // Not necessary to show error message if the error was caused | |
1010 // by I/O problems after the rfb.close() method call. | |
1011 System.out.println("RFB thread finished"); | |
1012 return; | |
1013 } | |
1014 | |
1015 System.out.println(str); | |
1016 e.printStackTrace(); | |
1017 | |
1018 if (rfb != null) | |
1019 rfb.close(); | |
1020 | |
1021 if (inAnApplet) { | |
1022 showMessage(str); | |
1023 } else { | |
1024 System.exit(1); | |
1025 } | |
1026 } | |
60 | 1027 |
20 | 1028 // |
1029 // Show message text and optionally "Relogin" and "Close" buttons. | |
1030 // | |
1031 | |
1032 void showMessage(String msg) { | |
1033 vncContainer.removeAll(); | |
1034 | |
1035 Label errLabel = new Label(msg, Label.CENTER); | |
1036 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12)); | |
1037 | |
1038 if (offerRelogin) { | |
1039 | |
1040 Panel gridPanel = new Panel(new GridLayout(0, 1)); | |
1041 Panel outerPanel = new Panel(new FlowLayout(FlowLayout.LEFT)); | |
1042 outerPanel.add(gridPanel); | |
1043 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 16)); | |
1044 vncContainer.add(outerPanel); | |
1045 Panel textPanel = new Panel(new FlowLayout(FlowLayout.CENTER)); | |
1046 textPanel.add(errLabel); | |
1047 gridPanel.add(textPanel); | |
1048 gridPanel.add(new ReloginPanel(this)); | |
1049 | |
1050 } else { | |
1051 | |
1052 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30)); | |
1053 vncContainer.add(errLabel); | |
1054 | |
1055 } | |
1056 | |
1057 if (inSeparateFrame) { | |
1058 vncFrame.pack(); | |
1059 } else { | |
1060 validate(); | |
1061 } | |
1062 } | |
1063 | |
1064 // | |
1065 // Stop the applet. | |
1066 // Main applet thread will terminate on first exception | |
1067 // after seeing that rfbThread has been set to null. | |
1068 // | |
1069 | |
1070 public void stop() { | |
1071 System.out.println("Stopping applet"); | |
1072 rfbThread = null; | |
1073 } | |
1074 | |
1075 // | |
1076 // This method is called before the applet is destroyed. | |
1077 // | |
1078 | |
1079 public void destroy() { | |
1080 System.out.println("Destroying applet"); | |
1081 | |
1082 vncContainer.removeAll(); | |
1083 options.dispose(); | |
1084 clipboard.dispose(); | |
1085 if (rec != null) | |
1086 rec.dispose(); | |
1087 if (rfb != null && !rfb.closed()) | |
1088 rfb.close(); | |
1089 if (inSeparateFrame) | |
1090 vncFrame.dispose(); | |
1091 } | |
1092 | |
1093 // | |
1094 // Start/stop receiving mouse events. | |
1095 // | |
1096 | |
1097 public void enableInput(boolean enable) { | |
1098 vc.enableInput(enable); | |
1099 } | |
1100 | |
1101 // | |
1102 // Close application properly on window close event. | |
1103 // | |
1104 | |
1105 public void windowClosing(WindowEvent evt) { | |
1106 System.out.println("Closing window"); | |
1107 if (rfb != null) | |
1108 disconnect(); | |
1109 | |
1110 vncContainer.hide(); | |
1111 | |
1112 if (!inAnApplet) { | |
1113 System.exit(0); | |
1114 } | |
1115 } | |
1116 | |
1117 // | |
1118 // Ignore window events we're not interested in. | |
1119 // | |
1120 | |
1121 public void windowActivated(WindowEvent evt) { | |
1122 } | |
1123 | |
1124 public void windowDeactivated(WindowEvent evt) { | |
1125 } | |
1126 | |
1127 public void windowOpened(WindowEvent evt) { | |
1128 } | |
1129 | |
1130 public void windowClosed(WindowEvent evt) { | |
1131 } | |
1132 | |
1133 public void windowIconified(WindowEvent evt) { | |
1134 } | |
1135 | |
1136 public void windowDeiconified(WindowEvent evt) { | |
1137 } | |
72 | 1138 |
79 | 1139 public void getParentName() { |
85
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1140 if (echoValue == null) { |
72 | 1141 |
85
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1142 if (clientSocket == null) { |
79 | 1143 |
85
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1144 // echo = new EchoClient(pHost, this); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1145 echoValue = new EchoClient(pHost, this, echoPort); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1146 echoValue.openport(); |
72 | 1147 |
85
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1148 echoValue = echoValue.hostn("1"); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1149 } else { |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1150 echoValue = new EchoClient(); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1151 echoValue = echoValue.Interruption(clientSocket); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1152 } |
72 | 1153 } |
85
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1154 // proxyからの返信で接続先を決定する |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1155 host = echoValue.responseLine; |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1156 parent = echoValue.parent; |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1157 if (echoValue.treenum != null) { |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1158 treenum = echoValue.treenum; |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1159 } else { |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1160 treenum = echoValue.treenum; |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1161 } |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1162 if (echoValue.leaderflag != null) { |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1163 leaderflag = echoValue.leaderflag; |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1164 } else { |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1165 leaderflag = echoValue.leaderflag; |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1166 } |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1167 System.out.println("Parent =" + parent); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1168 System.out.println("mynumber =" + treenum); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1169 System.out.println("connect host =" + host); |
ba6e672cc47c
update EchoClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
1170 System.out.println("leaderflag(boolean) = " + leaderflag); |
72 | 1171 |
73 | 1172 } |
32 | 1173 |
79 | 1174 public void setEchoValue(EchoClient value) { |
1175 this.echoValue = value; | |
1176 } | |
73 | 1177 int castByteInt(byte[] b) { |
1178 ByteBuffer bb = ByteBuffer.wrap(b); | |
1179 int value = bb.getInt(); | |
1180 return value; | |
1181 } | |
30 | 1182 |
60 | 1183 public void setClientSocket(Socket sock) { |
1184 clientSocket = sock; | |
1185 } | |
79 | 1186 |
71 | 1187 public void close() { |
1188 rfb.close(); | |
1189 vncFrame.setVisible(false); | |
1190 vncFrame.dispose(); | |
1191 } | |
60 | 1192 |
1193 | |
20 | 1194 } |