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