diff src/main/java/ac/ryukyu/treevnc/client/MyVncClient.java @ 2:dca3bd61b830

before change MyVncClient.java
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Mon, 09 Jul 2012 18:47:33 +0900
parents 75b54fd9e73a
children e7ce2b2ffed8
line wrap: on
line diff
--- a/src/main/java/ac/ryukyu/treevnc/client/MyVncClient.java	Tue Jul 03 13:34:43 2012 +0900
+++ b/src/main/java/ac/ryukyu/treevnc/client/MyVncClient.java	Mon Jul 09 18:47:33 2012 +0900
@@ -15,6 +15,8 @@
 import com.glavsoft.exceptions.TransportException;
 import com.glavsoft.exceptions.UnsupportedProtocolVersionException;
 import com.glavsoft.exceptions.UnsupportedSecurityTypeException;
+import com.glavsoft.rfb.IChangeSettingsListener;
+import com.glavsoft.rfb.IRfbSessionListener;
 import com.glavsoft.rfb.protocol.Protocol;
 import com.glavsoft.rfb.protocol.ProtocolSettings;
 import com.glavsoft.transport.Reader;
@@ -31,8 +33,8 @@
 
 import ac.ryukyu.treevnc.InterfaceForViewer;
 
-public class MyVncClient extends Viewer implements InterfaceForViewer,
-		java.lang.Runnable, WindowListener {
+public class MyVncClient extends Viewer implements Runnable, 
+ 	IRfbSessionListener, WindowListener, IChangeSettingsListener {
 
 	/**
 	 * 
@@ -93,7 +95,7 @@
 		if (mainArgs.length != 0) {
 			for (int i = 0; i < argv.length; i++) {
 				if ("-c".equals(argv[i])) {
-					// later write
+					// write later
 				}
 			}
 		} else {
@@ -108,7 +110,9 @@
 			System.exit(0);
 		}
 		MyVncClient myClient = new MyVncClient(parser);
-		SwingUtilities.invokeLater(myClient);
+		//SwingUtilities.invokeLater(myClient);
+		Thread th = new Thread(myClient);
+		th.start();
 	}
 	
 	private void getHostData() {
@@ -119,19 +123,22 @@
 		runBcast = new Thread(getBcast);
 		runBcast.start();
 		getBcast.setStopFlag(true);
-		connectionParams.hostName = getBcast.text.getAddress();
+		connectionParams.hostName = getBcast.textAddress();
 		if("notFound".equals(pHost)) {
 			getHost = new TextBoxClient();
 			getHost.ipRegister();
 			connectionParams.hostName = getHost.getAddressOption();
-			connectionParams.portNumber = Integer.parseInt(getHost.getPortOption());
+			//connectionParams.portNumber = Integer.parseInt(getHost.getPortOption());
+			connectionParams.portNumber = 5900;
 		} else {
-			connectionParams.portNumber = Integer.parseInt(getBcast.text.getPort());
+			//connectionParams.portNumber = Integer.parseInt(getBcast.textPort());
+			connectionParams.portNumber = 5900;
 		}
 	}
 
 	@Override
 	public void run() {
+	//	getHostData();
 		ConnectionManager connectionManager = new ConnectionManager(this, isApplet);
 		if (forceReconnection) {
 			connectionManager.showReconnectDialog("Connection lost", reconnectionReason);
@@ -139,6 +146,7 @@
 		}
 		tryAgain = true;
 		while (tryAgain) {
+		//	workingSocket = connectionManager.connectToTreeHost(connectionParams, settings);
 			workingSocket = connectionManager.connectToHost(connectionParams, settings);
 			if (null == workingSocket) {
 				closeApp();
@@ -196,41 +204,7 @@
 
 
 
-	@Override
-	public void setEchoValue(EchoClient value) {
-		// TODO Auto-generated method stub
 
-	}
-
-	@Override
-	public String readParameter(String name, boolean required) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void getParentName() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void disconnect() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fatalError(String str) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fatalError(String str, Exception e) {
-		// TODO Auto-generated method stub
-
-	}
 
 	@Override
 	public void destroy() {
@@ -239,75 +213,29 @@
 	}
 
 	@Override
-	public void enableInput(boolean enable) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setClientSocket(Socket sock) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void close() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public Image getScreenImage() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void writeScreenData(byte[] b, String imageFormat) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void windowActivated(WindowEvent e) {
-		// TODO Auto-generated method stub
-
+	public void windowClosing(WindowEvent e) {
+		if (e != null && e.getComponent() != null) {
+			e.getWindow().setVisible(false);
+		}
+		closeApp();
 	}
 
 	@Override
-	public void windowClosed(WindowEvent e) {
-		// TODO Auto-generated method stub
-
-	}
+	public void windowActivated(WindowEvent e) { /*nop*/ }
 
 	@Override
-	public void windowClosing(WindowEvent e) {
-		// TODO Auto-generated method stub
-
-	}
+	public void windowClosed(WindowEvent e) { /*nop*/ }
 
 	@Override
-	public void windowDeactivated(WindowEvent e) {
-		// TODO Auto-generated method stub
-
-	}
+	public void windowDeactivated(WindowEvent e) { /*nop*/ }
 
 	@Override
-	public void windowDeiconified(WindowEvent e) {
-		// TODO Auto-generated method stub
-
-	}
+	public void windowDeiconified(WindowEvent e) { /*nop*/ }
 
 	@Override
-	public void windowIconified(WindowEvent e) {
-		// TODO Auto-generated method stub
-
-	}
+	public void windowIconified(WindowEvent e) { /*nop*/ }
 
 	@Override
-	public void windowOpened(WindowEvent e) {
-		// TODO Auto-generated method stub
-
-	}
+	public void windowOpened(WindowEvent e) { /*nop*/ }
 
 }