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