diff src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 36:b7d4d0349f99

write part of reconnection and remove warning.
author one
date Tue, 18 Sep 2012 17:23:19 +0900
parents 1b81deb0abb3
children c2f0b6907448
line wrap: on
line diff
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Wed Sep 12 13:16:47 2012 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Tue Sep 18 17:23:19 2012 +0900
@@ -289,7 +289,8 @@
 	
 		tryAgain = true;
 		while (tryAgain) {
-			workingSocket = connectionManager.connectToHost(connectionParams, settings, rfb);
+			if(workingSocket==null)
+				workingSocket = connectionManager.connectToHost(connectionParams, settings, rfb);
 			if (null == workingSocket) {
 				closeApp();
 				break;
@@ -318,6 +319,7 @@
 				connectionManager.setContainerFrame(containerFrame);
 				updateFrameTitle();
 				if(rfb != null) {
+					rfb.setViewer(this);
 					runAcceptThread();
 					rfb.setProtocolContext(workingProtocol);
 					rfb.notProxy();
@@ -634,4 +636,21 @@
 		Viewer viewer = new Viewer(parser);
 		SwingUtilities.invokeLater(viewer);
 	}
+	
+	public void setSocket(Socket soc) {
+		workingSocket = soc;
+	}
+	
+	public void close() {
+		try {
+			workingProtocol.getWriter().close();
+			workingProtocol.getReader().close();
+			cleanUpUISessionAndConnection();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (TransportException e) {
+			e.printStackTrace();
+		}
+	}
+
 }