comparison src/myVncClient/CuiMyVncClient.java @ 80:3bfe8845684c

modify MyVncClient
author e085711
date Wed, 31 Aug 2011 15:15:23 +0900
parents c76e43a12796
children d3e806372657 3ea33e683522
comparison
equal deleted inserted replaced
79:c76e43a12796 80:3bfe8845684c
10 import myVncClient.AcceptThread; 10 import myVncClient.AcceptThread;
11 import myVncClient.OptionsNoFrame; 11 import myVncClient.OptionsNoFrame;
12 12
13 public class CuiMyVncClient implements InterfaceForViewer { 13 public class CuiMyVncClient implements InterfaceForViewer {
14 14
15 public static void main(String[] argv) {
16 CuiMyVncClient v = new CuiMyVncClient();
17 v.echoValue = null;
18 v.runClient(argv, v);
19
20 }
21
22 private void runClient(String[] argv, CuiMyVncClient v) {
23 mainArgs = argv;
24
25 host = mainArgs[0];
26 port = Integer.parseInt(mainArgs[1]);
27
28 v.init();
29 v.start_threads();
30
31 }
32 15
33 String[] mainArgs; 16 String[] mainArgs;
34 String username; 17 String username;
35 18
36 // RfbProto rfb; 19 // RfbProto rfb;
82 boolean runflag = false; 65 boolean runflag = false;
83 boolean first = true; 66 boolean first = true;
84 67
85 EchoClient echoValue; 68 EchoClient echoValue;
86 int echoPort; 69 int echoPort;
70 String pHost;
71
72 public static void main(String[] argv) {
73 CuiMyVncClient v = new CuiMyVncClient();
74 v.echoValue = null;
75 v.runClient(argv, v);
76
77 }
78
79 private void runClient(String[] argv, CuiMyVncClient v) {
80 mainArgs = argv;
81
82 if (mainArgs.length > 0)
83 pHost = mainArgs[0];
84 else
85 pHost = "cls080.ie.u-ryukyu.ac.jp";
86 if (mainArgs.length > 1)
87 port = Integer.parseInt(mainArgs[1]);
88 else
89 port = 5999;
90
91 v.init();
92 v.start_threads();
93
94 }
87 95
88 96
89 void checkArgs(String[] argv) { 97 void checkArgs(String[] argv) {
90 if (argv.length > 3) { 98 if (argv.length > 3) {
91 username = argv[3]; 99 username = argv[3];
293 showConnectionStatus("Initializing..."); 301 showConnectionStatus("Initializing...");
294 302
295 showConnectionStatus("Connecting to " + host + ", port " + port + "..."); 303 showConnectionStatus("Connecting to " + host + ", port " + port + "...");
296 304
297 // rfb = new RfbProto(host, port, this); 305 // rfb = new RfbProto(host, port, this);
298 rfb = new MyRfbProto(host, port); 306 rfb = new MyRfbProto(pHost, port);
299 307
300 showConnectionStatus("Connected to server"); 308 showConnectionStatus("Connected to server");
301 309
302 rfb.readVersionMsg(); 310 rfb.readVersionMsg();
303 showConnectionStatus("RFB server supports protocol version " 311 showConnectionStatus("RFB server supports protocol version "
304 + rfb.serverMajor + "." + rfb.serverMinor); 312 + rfb.serverMajor + "." + rfb.serverMinor);
305 313
306 rfb.writeVersionMsg(); 314 rfb.writeVersionMsg();
307 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor 315 showConnectionStatus("Using RFB protocol version " + rfb.clientMajor
308 + "." + rfb.clientMinor); 316 + "." + rfb.clientMinor);
317
309 318
310 if(rfb.serverMinor == 998) { 319 if(rfb.serverMinor == 998) {
311 byte[] b = new byte[4]; 320 byte[] b = new byte[4];
312 b = rfb.readEchoPort(); 321 b = rfb.readEchoPort();
313 echoPort = castByteInt(b); 322 echoPort = castByteInt(b);
314 323
315 String hs = host; 324 InetAddress addr = InetAddress.getByName(pHost);
316 InetAddress addr = InetAddress.getByName(host);
317 String h = new String(addr.getHostAddress()); 325 String h = new String(addr.getHostAddress());
318 326
319 getParentName(); 327 getParentName();
320 if(!(h.equals(host))) { 328 if(!(h.equals(host))) {
321 rfb.changeParent(host, port); 329 rfb.changeParent(host, port);
986 public void start() { 994 public void start() {
987 995
988 } 996 }
989 public void close() { 997 public void close() {
990 rfb.close(); 998 rfb.close();
991 vncFrame.setVisible(false);
992 vncFrame.dispose();
993 } 999 }
994 public void getParentName() { 1000 public void getParentName() {
995 if (echoValue == null) { 1001 if (echoValue == null) {
996 1002
997 if (clientSocket == null) { 1003 if (clientSocket == null) {