changeset 71:f6cb1edc2036

modify EchoClient.java. System.exit(0)
author e085711
date Mon, 29 Aug 2011 01:39:15 +0900
parents affdcbdc90ea
children ec66d1d4dca0
files src/myVncClient/CuiMyVncClient.java src/myVncClient/EchoClient.java src/myVncClient/InterfaceForViewer.java src/myVncClient/MyRfbProto.java src/myVncClient/MyVncClient.java src/myVncClient/VncCanvas.java src/myVncClient/WaitReply.java
diffstat 7 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncClient/CuiMyVncClient.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/CuiMyVncClient.java	Mon Aug 29 01:39:15 2011 +0900
@@ -192,7 +192,7 @@
 				echo.openport();
 				// runflag = echo.losthost();
 				if (echo.losthost()) {
-					return;
+					break;
 				}
 				counter++;
 			}
@@ -984,5 +984,10 @@
 	public void start() {
 
 	}
+	public void close() {
+		rfb.close();
+		vncFrame.setVisible(false);
+		vncFrame.dispose();
+	}
 
 }
--- a/src/myVncClient/EchoClient.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/EchoClient.java	Mon Aug 29 01:39:15 2011 +0900
@@ -74,6 +74,7 @@
 		} catch (IOException e) {
 			System.out.println("接続に失敗しました");
 			System.err.println("Couldn't get I/O for the connection to: localhost");
+			System.exit(0);
 		}
 	}
 
--- a/src/myVncClient/InterfaceForViewer.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/InterfaceForViewer.java	Mon Aug 29 01:39:15 2011 +0900
@@ -24,5 +24,6 @@
 	
 
 	public void setClientSocket(Socket sock);
+	public void close();
 	
 }
--- a/src/myVncClient/MyRfbProto.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/MyRfbProto.java	Mon Aug 29 01:39:15 2011 +0900
@@ -324,7 +324,7 @@
 		rectW = readU16();           //  8
 		rectH = readU16();           //  10
 		encoding = readU32();      //   12
-		// System.out.println("encoding = "+encoding);
+		System.out.println("encoding = "+encoding);
 		if (encoding == EncodingZRLE|| encoding==EncodingZRLEE||encoding==EncodingZlib)
 			zLen = readU32();
 		else
--- a/src/myVncClient/MyVncClient.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/MyVncClient.java	Mon Aug 29 01:39:15 2011 +0900
@@ -10,7 +10,7 @@
 		WindowListener {
 
 	/**
-	 * e
+	 * 
 	 */
 	private static final long serialVersionUID = 1L;
 	boolean inAnApplet = true;
@@ -107,8 +107,8 @@
 
 		try {
 
-			connectAndAuthenticate();
 			if (first) {
+				connectAndAuthenticate();
 				accThread = new Thread(new AcceptThread(rfb, 5999));
 				accThread.start();
 				first = false;
@@ -225,7 +225,6 @@
 			fatalError("Network error: could not connect to server: " + host
 					+ ":" + port, e);
 		} catch (EOFException e) {
-			System.out.println("EOFException : rfb.sock.close()");
 			
 			vncFrame.setVisible(false);
 			vncFrame.dispose();
@@ -388,8 +387,16 @@
 	}
 
 	void reConnectAndAuthenticate() throws Exception {
+
 		showConnectionStatus("Initializing...");
 
+		if (inSeparateFrame) {
+			vncFrame.pack();
+			vncFrame.setVisible(true);
+		} else {
+			validate();
+		}		
+
 		showConnectionStatus("Connecting to " + host + ", port " + port + "...");
 
 		rfb.changeParent(host, port);
@@ -1145,6 +1152,11 @@
 	public void setClientSocket(Socket sock) {
 		clientSocket = sock;
 	}
+	public void close() {
+		rfb.close();
+		vncFrame.setVisible(false);
+		vncFrame.dispose();
+	}
 
 
 }
--- a/src/myVncClient/VncCanvas.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/VncCanvas.java	Mon Aug 29 01:39:15 2011 +0900
@@ -395,7 +395,7 @@
 			 *  read Data from parents and send Data to Client.
 			 *  
 			 */
-			rfb.sendDataToClient();
+//			rfb.sendDataToClient();
 
 			int bufSize = (int)rfb.getNumBytesRead();
 			
@@ -496,6 +496,9 @@
 					
 					rfb.stopTiming();
 
+					long kbitsPerSecond = rfb.kbitsPerSecond();
+//					System.out.println("kbitsPerSecond = " + kbitsPerSecond);
+					
 					statNumPixelRects++;
 					statNumBytesDecoded += rw * rh * bytesPixel;
 					statNumBytesEncoded += (int) (rfb.getNumBytesRead() - numBytesReadBefore);
--- a/src/myVncClient/WaitReply.java	Sun Aug 07 13:40:56 2011 +0900
+++ b/src/myVncClient/WaitReply.java	Mon Aug 29 01:39:15 2011 +0900
@@ -38,6 +38,8 @@
 			try {
 			clientSocket = echoServer.accept();
 			if(clientSocket != null){
+				client.close();
+				
 //				client.clientSocket = clientSocket;
 				client.setClientSocket(clientSocket);
 				client.init(null);