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