changeset 80:3bfe8845684c

modify MyVncClient
author e085711
date Wed, 31 Aug 2011 15:15:23 +0900
parents c76e43a12796
children a542f92500ab 2eb52d563a05 143c52bf3a94
files src/myVncClient/CuiMyVncClient.java src/myVncClient/MyVncClient.java src/myVncClient/WaitReply.java
diffstat 3 files changed, 31 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncClient/CuiMyVncClient.java	Wed Aug 31 13:34:32 2011 +0900
+++ b/src/myVncClient/CuiMyVncClient.java	Wed Aug 31 15:15:23 2011 +0900
@@ -12,23 +12,6 @@
 
 public class CuiMyVncClient implements InterfaceForViewer {
 
-	public static void main(String[] argv) {
-		CuiMyVncClient v = new CuiMyVncClient();
-		v.echoValue = null;
-		v.runClient(argv, v);
-
-	}
-
-	private void runClient(String[] argv, CuiMyVncClient v) {
-		mainArgs = argv;
-		
-		host = mainArgs[0];
-		port = Integer.parseInt(mainArgs[1]);
-
-		v.init();
-		v.start_threads();
-
-	}
 
 	String[] mainArgs;
 	String username;
@@ -84,6 +67,31 @@
 
 	EchoClient echoValue;
 	int echoPort;
+	String pHost;
+
+	public static void main(String[] argv) {
+		CuiMyVncClient v = new CuiMyVncClient();
+		v.echoValue = null;
+		v.runClient(argv, v);
+
+	}
+
+	private void runClient(String[] argv, CuiMyVncClient v) {
+		mainArgs = argv;
+		
+		if (mainArgs.length > 0)
+			pHost = mainArgs[0];
+		else
+			pHost = "cls080.ie.u-ryukyu.ac.jp";
+		if (mainArgs.length > 1)
+			port = Integer.parseInt(mainArgs[1]);
+		else
+			port = 5999;
+
+		v.init();
+		v.start_threads();
+
+	}
 	
 	
 	void checkArgs(String[] argv) {
@@ -295,7 +303,7 @@
 		showConnectionStatus("Connecting to " + host + ", port " + port + "...");
 
 		// rfb = new RfbProto(host, port, this);
-		rfb = new MyRfbProto(host, port);
+		rfb = new MyRfbProto(pHost, port);
 
 		showConnectionStatus("Connected to server");
 
@@ -307,13 +315,13 @@
 		showConnectionStatus("Using RFB protocol version " + rfb.clientMajor
 				+ "." + rfb.clientMinor);
 
+
 		if(rfb.serverMinor == 998) {
 			byte[] b = new byte[4];
 			b = rfb.readEchoPort();
 			echoPort = castByteInt(b);
 
-			String hs = host;
-			InetAddress addr = InetAddress.getByName(host);
+			InetAddress addr = InetAddress.getByName(pHost);
 			String h = new String(addr.getHostAddress());
 			
 			getParentName();
@@ -988,8 +996,6 @@
 	}
 	public void close() {
 		rfb.close();
-		vncFrame.setVisible(false);
-		vncFrame.dispose();
 	}
 	public void getParentName() {
 		if (echoValue == null) {
--- a/src/myVncClient/MyVncClient.java	Wed Aug 31 13:34:32 2011 +0900
+++ b/src/myVncClient/MyVncClient.java	Wed Aug 31 15:15:23 2011 +0900
@@ -246,8 +246,7 @@
 			vncFrame.setVisible(false);
 			vncFrame.dispose();
 			// num4
-			// リーダーの子ノードがproxyに対して親が落ちたことを報告をする
-			if (leaderflag != null) {
+			if ( leaderflag != null) {
 				while (true) {
 					echoValue = new EchoClient(echoValue, this);
 					echoValue.openport();
--- a/src/myVncClient/WaitReply.java	Wed Aug 31 13:34:32 2011 +0900
+++ b/src/myVncClient/WaitReply.java	Wed Aug 31 15:15:23 2011 +0900
@@ -36,6 +36,8 @@
 					// client.clientSocket = clientSocket;
 					client.setClientSocket(clientSocket);
 					client.init();
+					client.setEchoValue(null);
+					client.getParentName();
 					client.start_threads();
 					client.start();
 					// MyVncClient.main(clientSocket);