changeset 45:20326a4b9d88

create new change button for client.
author one
date Tue, 04 Dec 2012 17:56:39 +0900
parents d4663dfd91ae
children d2741b80399e
files dist/tightvnc-jviewer-2.5.0/tightvnc-jviewer.jar src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/GetDataClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java src/viewer_swing/java/com/glavsoft/viewer/TreeConnectionManager.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java
diffstat 9 files changed, 199 insertions(+), 165 deletions(-) [+]
line wrap: on
line diff
Binary file dist/tightvnc-jviewer-2.5.0/tightvnc-jviewer.jar has changed
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Tue Dec 04 17:56:39 2012 +0900
@@ -1,7 +1,9 @@
 package jp.ac.u_ryukyu.treevnc;
 
+import java.io.DataOutputStream;
 import java.io.IOException;
 import java.net.Socket;
+import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.LinkedList;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -27,6 +29,7 @@
 	private RequestScreenThread rThread;
 	private boolean proxyFlag = true;
 	private EchoClient echo;
+	private String proxyAddr;
 	
 	public MyRfbProto() {
 		rThread = new RequestScreenThread(this);
@@ -221,6 +224,17 @@
 		}
 		return rfbMinor;
 	}
+		
+	public void screenChangeRequest() throws IOException {
+		Socket echoSocket;
+		echoSocket = new Socket(proxyAddr, 10001);
+		DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream());
+		os.writeBytes(echo.getMyAddress()+"\n");
+		System.out.println("---------push-------");
+		// os.writeBytes("1240\n");
+		// os.writeBytes("880\n");
+		os.close();
+	}
 	
 	private void sendProxyFlag(Writer writer) throws TransportException {
 		if (proxyFlag)
@@ -245,6 +259,7 @@
 		return b;
 	}
 	
+	
 	private void readSecType(Reader reader) throws TransportException {
 		byte[] b = new byte[1];
 		reader.read(b);
@@ -317,7 +332,6 @@
 		proxyFlag = false;
 	}
 
-
 	public void setEcho(EchoClient _echo) {
 		echo = _echo;
 	}
@@ -330,7 +344,6 @@
 		return echo;
 	}
 
-
 	public void setTerminationType(boolean setType) {
 		/*nop*/
 	}
@@ -339,4 +352,9 @@
 		/*nop*/
 		return true;
 	}
+
+	public void setProxyAddr(String proxyAddr) {
+		this.proxyAddr = proxyAddr;
+	}
+	
 }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java	Tue Dec 04 17:56:39 2012 +0900
@@ -3,32 +3,34 @@
 import java.io.*;
 import java.net.*;
 
+
 import com.glavsoft.viewer.Viewer;
 
 public class EchoClient {
-	private String name;
+	private String proxyName;
 	private BufferedReader is = null;
 	private DataOutputStream os = null;
 	private Socket echoSocket = null;
 	private boolean runflag = false;
 	private WaitReply waitReply;
 	private Socket clientSocket = null;
+	private int echoPort = 9999;
 	Viewer client;
-	private int echoPort = 9999;
 	public String parentAddress;
 	public String parentNum;
 	public String treeNum;
 	public String leaderFlag;
+	private String myAddress;
 
 	public EchoClient(String name, int echoPort) {
 		this.echoPort = echoPort;
-		this.name = name;
+		this.proxyName = name;
 	}
 
 	public void openport() {
 		try {
 			// if(echoSocket==null)
-			echoSocket = new Socket(name, echoPort);
+			echoSocket = new Socket(proxyName, echoPort);
 			echoSocket.setReuseAddress(true);
 			os = new DataOutputStream(echoSocket.getOutputStream());
 			is = new BufferedReader(new InputStreamReader(
@@ -36,7 +38,7 @@
 		} catch (UnknownHostException e) {
 			System.err.println("Don't know about host: localhost");
 		} catch (IOException e) {
-			System.out.println(name + " Connection Faild");
+			System.out.println(proxyName + " Connection Faild");
 			System.exit(0);
 		}
 
@@ -52,10 +54,10 @@
 			try {
 
 				InetAddress addr = InetAddress.getLocalHost();
-				String add = new String(addr.getHostAddress());
+				myAddress = new String(addr.getHostAddress());
 				// add = getIpV6();
 
-				os.writeBytes(add + "\n");
+				os.writeBytes(myAddress + "\n");
 				os.writeBytes(args + "\n");
 				getProxyData(is);
 
@@ -175,7 +177,6 @@
 				client.run();
 				break;
 			} catch (IOException e) {
-				System.out.println("EchoClient L178");
 				continue;
 			}
 		}
@@ -207,7 +208,6 @@
 				os.writeBytes(type + "\n");
 				os.writeBytes(num + "\n");
 			}
-
 		} catch (UnknownHostException e) {
 			System.err.println("Trying to connect to unknown host: " + e);
 		} catch (IOException e) {
@@ -228,6 +228,10 @@
 	public void setViewer(Viewer v) {
 		client = v;
 	}
+	
+	public String getMyAddress() {
+		return myAddress;
+	}
 
 	public Socket createSocketForClient(Socket soc) throws IOException {
 		BufferedReader is = new BufferedReader(new InputStreamReader(
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetDataClient.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetDataClient.java	Tue Dec 04 17:56:39 2012 +0900
@@ -13,6 +13,7 @@
 	private int port = 8182;
 	private boolean stopFlag;
 	private TextBoxClient text = new TextBoxClient();
+	private String proxyAddr;
 		
 	
 	public String textAddress() {
@@ -63,10 +64,10 @@
 				Socket socket = server.accept();  
 				is = new BufferedReader(new InputStreamReader(
 						socket.getInputStream()));
-				String line = is.readLine();
+				proxyAddr = is.readLine();
 //				text = new TextBoxClient();
-				if(line!=null)
-					text.checkBox(line);
+				if(proxyAddr!=null)
+					text.checkBox(proxyAddr);
 				// TextBoxClient text = new TextBoxClient();
 				text.setButton();
 				text.visible();
@@ -94,4 +95,7 @@
 		text.ipRegister();
 	}
 
+	public String getProxyAddr() {
+		return proxyAddr;
+	}
 }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java	Tue Dec 04 17:56:39 2012 +0900
@@ -6,6 +6,7 @@
 import java.net.ServerSocket;
 import java.net.Socket;
 
+
 /**
  * this Class get top(Proxy) Instruction. 
  * Type of Instruction is ReConnection and SocketClose.
@@ -38,7 +39,6 @@
 					echo.client.setSocket(echo.createSocketForClient(clientSocket));
 					// hult();
 					// client.init();
-					System.out.println("------before run()");
 					echo.client.run();
 					echoServer.close();
 				}
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java	Tue Dec 04 17:56:39 2012 +0900
@@ -40,7 +40,6 @@
 	boolean printStatusFlag = false;
 	long startCheckTime;
 
-
 	private ServerSocket servSock;
 	protected int acceptPort;
 	// private byte initData[];
@@ -54,7 +53,8 @@
 
 	// private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new
 	// MostRecentMultiCast<LinkedList<ByteBuffer>>(10);
-//	private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>();
+	// private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new
+	// MulticastQueue<LinkedList<ByteBuffer>>();
 	private Inflater inflater = new Inflater();
 	private Deflater deflater = new Deflater();
 	// private Thread requestThread;
@@ -67,7 +67,7 @@
 	}
 
 	public void setStream(Writer _writer) {
-//		os = _writer;
+		// os = _writer;
 	}
 
 	void initServSock(int port) throws IOException {
@@ -108,7 +108,7 @@
 	public Socket accept() throws IOException {
 		return servSock.accept();
 	}
-	
+
 	public void socketClose() throws IOException {
 		servSock.close();
 	}
@@ -243,7 +243,7 @@
 	 * send data to clients
 	 * 
 	 * @param dataLen
-	 * @param is 
+	 * @param is
 	 * @throws IOException
 	 * @throws DataFormatException
 	 * 
@@ -301,7 +301,7 @@
 				} catch (IOException e) {
 					throw new TransportException(e);
 				}
-				
+
 				ByteBuffer blen = ByteBuffer.allocate(4);
 				blen.putInt(len2);
 				blen.flip();
@@ -361,83 +361,50 @@
 	}
 
 	/*
-	@Test
-	public void test1() {
-		try {
-			LinkedList<ByteBuffer> in = new LinkedList<ByteBuffer>();
-			LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>();
-			LinkedList<ByteBuffer> out2 = new LinkedList<ByteBuffer>();
-			// if (false) {
-			// for(int i=0;i<10;i++) {
-			// in.add(ByteBuffer.wrap("test1".getBytes()));
-			// in.add(ByteBuffer.wrap("test2".getBytes()));
-			// in.add(ByteBuffer.wrap("test3".getBytes()));
-			// in.add(ByteBuffer.wrap("test44".getBytes()));
-			// }
-			// } else
-			{
-				String t = "";
-				for (int i = 0; i < 10; i++) {
-					t += "test1";
-					t += "test2";
-					t += "test3";
-					t += "test44";
-				}
-				in.add(ByteBuffer.wrap(t.getBytes()));
-			}
-
-			LinkedList<ByteBuffer> in1 = clone(in);
+	 * @Test public void test1() { try { LinkedList<ByteBuffer> in = new
+	 * LinkedList<ByteBuffer>(); LinkedList<ByteBuffer> out = new
+	 * LinkedList<ByteBuffer>(); LinkedList<ByteBuffer> out2 = new
+	 * LinkedList<ByteBuffer>(); // if (false) { // for(int i=0;i<10;i++) { //
+	 * in.add(ByteBuffer.wrap("test1".getBytes())); //
+	 * in.add(ByteBuffer.wrap("test2".getBytes())); //
+	 * in.add(ByteBuffer.wrap("test3".getBytes())); //
+	 * in.add(ByteBuffer.wrap("test44".getBytes())); // } // } else { String t =
+	 * ""; for (int i = 0; i < 10; i++) { t += "test1"; t += "test2"; t +=
+	 * "test3"; t += "test44"; } in.add(ByteBuffer.wrap(t.getBytes())); }
+	 * 
+	 * LinkedList<ByteBuffer> in1 = clone(in);
+	 * 
+	 * Deflater deflater = new Deflater(); zip(deflater, in, 0, out); //
+	 * LinkedList<ByteBuffer> out3 = clone(out); zipped result is depend // on
+	 * deflator's state unzip(inflater, out, 0, out2, INFLATE_BUFSIZE); //
+	 * inflater.reset(); equalByteBuffers(in1, out2); LinkedList<ByteBuffer>
+	 * out4 = new LinkedList<ByteBuffer>(); deflater = new Deflater();
+	 * zip(deflater, out2, 0, out4); LinkedList<ByteBuffer> out5 = new
+	 * LinkedList<ByteBuffer>(); unzip(inflater, out4, 0, out5,
+	 * INFLATE_BUFSIZE); int len = equalByteBuffers(in1, out5);
+	 * 
+	 * System.out.println("Test Ok. " + len); } catch (Exception e) {
+	 * assertEquals(0, 1); } }
+	 */
 
-			Deflater deflater = new Deflater();
-			zip(deflater, in, 0, out);
-			// LinkedList<ByteBuffer> out3 = clone(out); zipped result is depend
-			// on deflator's state
-			unzip(inflater, out, 0, out2, INFLATE_BUFSIZE);
-			// inflater.reset();
-			equalByteBuffers(in1, out2);
-			LinkedList<ByteBuffer> out4 = new LinkedList<ByteBuffer>();
-			deflater = new Deflater();
-			zip(deflater, out2, 0, out4);
-			LinkedList<ByteBuffer> out5 = new LinkedList<ByteBuffer>();
-			unzip(inflater, out4, 0, out5, INFLATE_BUFSIZE);
-			int len = equalByteBuffers(in1, out5);
-
-			System.out.println("Test Ok. " + len);
-		} catch (Exception e) {
-			assertEquals(0, 1);
-		}
-	}
+	/*
+	 * public int equalByteBuffers(LinkedList<ByteBuffer> in,
+	 * LinkedList<ByteBuffer> out2) { int len = 0; Iterable<Byte> i =
+	 * byteBufferIterator(in); Iterator<Byte> o =
+	 * byteBufferIterator(out2).iterator();
+	 * 
+	 * for (int b : i) { len++; if (o.hasNext()) { int c = o.next();
+	 * assertEquals(b, c); } else assertEquals(0, 1); } if (o.hasNext())
+	 * assertEquals(0, 1); // System.out.println(); return len; }
 	 */
-	
-	/*
-	public int equalByteBuffers(LinkedList<ByteBuffer> in,
-			LinkedList<ByteBuffer> out2) {
-		int len = 0;
-		Iterable<Byte> i = byteBufferIterator(in);
-		Iterator<Byte> o = byteBufferIterator(out2).iterator();
-
-		for (int b : i) {
-			len++;
-			if (o.hasNext()) {
-				int c = o.next();
-				assertEquals(b, c);
-			} else
-				assertEquals(0, 1);
-		}
-		if (o.hasNext())
-			assertEquals(0, 1);
-		// System.out.println();
-		return len;
-	}
-	*/
-
 
 	void sendRfbVersion(Writer writer) throws IOException, TransportException {
 		// os.write(versionMsg_3_8.getBytes());
 		writer.write(versionMsg_3_855.getBytes());
 	}
 
-	int readVersionMsg(Reader reader, Writer writer) throws IOException, TransportException {
+	int readVersionMsg(Reader reader, Writer writer) throws IOException,
+			TransportException {
 
 		byte[] b = new byte[12];
 
@@ -476,7 +443,7 @@
 
 	void sendPortNumber(Writer writer) throws TransportException {
 		byte[] b = new byte[4];
-		//b = castIntByte(getHost.getPort());
+		// b = castIntByte(getHost.getPort());
 		b = castIntByte(9999);
 		writer.write(b);
 	}
@@ -554,5 +521,5 @@
 		byte[] b = new byte[0];
 		in.readBytes(b);
 	}
-	
+
 }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Tue Dec 04 17:56:39 2012 +0900
@@ -2,16 +2,16 @@
 
 import java.awt.event.*;
 import java.io.*;
+import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.UnknownHostException;
 import java.util.LinkedList;
 import java.util.logging.Logger;
 
 import jp.ac.u_ryukyu.treevnc.AcceptThread;
+import jp.ac.u_ryukyu.treevnc.client.WaitReply;
 import jp.ac.u_ryukyu.treevnc.server.state.ChangeHost;
 
-
-
 import com.glavsoft.exceptions.AuthenticationFailedException;
 import com.glavsoft.exceptions.FatalException;
 import com.glavsoft.exceptions.TransportException;
@@ -32,8 +32,8 @@
 import com.glavsoft.viewer.swing.UiSettings;
 import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams;
 
-public class VncProxyService extends Viewer implements Runnable, 
-	IRfbSessionListener, IChangeSettingsListener {
+public class VncProxyService extends Viewer implements Runnable,
+		IRfbSessionListener, IChangeSettingsListener {
 
 	/**
 	 * 
@@ -46,25 +46,27 @@
 	private CreateThread createThread;
 	public AcceptClient aClient;
 	public int opendPort;
+
 	// public AcceptClient acc;
 	public VncProxyService(Parser parser) {
 		this();
 		aClient = new AcceptClient();
-		ParametersHandler.completeSettingsFromCLI(parser, connectionParams, settings, uiSettings);
+		ParametersHandler.completeSettingsFromCLI(parser, connectionParams,
+				settings, uiSettings);
 		showControls = ParametersHandler.showControls;
 		passwordFromParams = parser.getValueFor(ParametersHandler.ARG_PASSWORD);
 		logger.info("TightVNC Viewer version " + ver());
 		isApplet = false;
 	}
-	
+
 	public VncProxyService() {
 		connectionManager = new ConnectionManager(this, isApplet);
 		connectionParams = new ParametersHandler.ConnectionParams();
 		settings = ProtocolSettings.getDefaultSettings();
 		uiSettings = super.uiSettings;
-		connectionParams.hostName="localhost";
+		connectionParams.hostName = "localhost";
 	}
-	
+
 	boolean isClient = false;
 	public static final int DEFAULT_PORT = 5900;
 	public static Logger logger = Logger.getLogger("com.glavsoft");
@@ -77,8 +79,7 @@
 	private GetBroadCastProxy getCast;
 
 	private Protocol tempWorkingProtocol;
-	
-	
+
 	public static void main(String[] argv) {
 		String[] mainArgs = argv;
 		System.out.println(mainArgs.length);
@@ -99,38 +100,36 @@
 				// write later
 			}
 		} else {
-			//getHostData();
+			// getHostData();
 		}
-		//SwingUtilities.invokeLater(myClient);
+		// SwingUtilities.invokeLater(myClient);
 		/*
-		Thread th = new Thread(vps);
-		th.start();
-		try {
-			th.join();
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		*/
+		 * Thread th = new Thread(vps); th.start(); try { th.join(); } catch
+		 * (InterruptedException e) { e.printStackTrace(); }
+		 */
 		vps.run();
 		vps.createConnectionAndStart();
 	}
-	
+
 	private void setArguments(String[] mainArgs) {
 	}
 
 	@Override
 	public void run() {
 		rfb = new MyRfbProtoProxy();
-	//	getHostData();
+		// getHostData();
 		if (forceReconnection) {
-			connectionManager.showReconnectDialog("Connection lost", reconnectionReason);
+			connectionManager.showReconnectDialog("Connection lost",
+					reconnectionReason);
 			forceReconnection = false;
 		}
 		tryAgain = true;
 		while (tryAgain) {
-		//  connectionParams.hostName = arguments[0];
-		//	workingSocket = connectionManager.connectToTreeHost(connectionParams, settings);
-			workingSocket = connectionManager.connectToHost(connectionParams, settings, rfb);
+			// connectionParams.hostName = arguments[0];
+			// workingSocket =
+			// connectionManager.connectToTreeHost(connectionParams, settings);
+			workingSocket = connectionManager.connectToHost(connectionParams,
+					settings, rfb);
 			if (null == workingSocket) {
 				closeApp();
 				break;
@@ -140,19 +139,22 @@
 				workingSocket.setTcpNoDelay(true); // disable Nagle algorithm
 				Reader reader = new Reader(workingSocket.getInputStream());
 				Writer writer = new Writer(workingSocket.getOutputStream());
-		//		rfb.setStream(reader,writer);
+				// rfb.setStream(reader,writer);
 				workingProtocol = new Protocol(reader, writer,
-						new PasswordChooser(passwordFromParams, connectionParams, containerFrame, this),
+						new PasswordChooser(passwordFromParams,
+								connectionParams, containerFrame, this),
 						settings);
 				workingProtocol.handshake();
 				rfb.setProtocolContext(workingProtocol);
 				threadSetAndStart();
 				// input into change parents
-                ClipboardControllerImpl clipboardController =
-		                new ClipboardControllerImpl(workingProtocol, settings.getRemoteCharsetName());
-				clipboardController.setEnabled(settings.isAllowClipboardTransfer());
+				ClipboardControllerImpl clipboardController = new ClipboardControllerImpl(
+						workingProtocol, settings.getRemoteCharsetName());
+				clipboardController.setEnabled(settings
+						.isAllowClipboardTransfer());
 				settings.addListener(clipboardController);
-				surface = new Surface(workingProtocol, this, uiSettings.getScaleFactor()); // this method
+				surface = new Surface(workingProtocol, this,
+						uiSettings.getScaleFactor()); // this method
 				settings.addListener(this);
 				uiSettings.addListener(surface);
 				containerFrame = createContainer();
@@ -160,35 +162,43 @@
 				updateFrameTitle();
 				containerFrame.dispose();
 				containerFrame = null;
-				if(tempWorkingProtocol!=null)
+				if (tempWorkingProtocol != null)
 					tempWorkingProtocol.cleanUpSession();
-				workingProtocol.startNormalHandling(this, surface, clipboardController,rfb);
+				workingProtocol.startNormalHandling(this, surface,
+						clipboardController, rfb);
 				// rfb.setInitData(workingProtocol.getInitData()); too early
-				// workingProtocol.startNormalHandling(this, surface, clipboardController);
+				// workingProtocol.startNormalHandling(this, surface,
+				// clipboardController);
 				tryAgain = false;
 			} catch (UnsupportedProtocolVersionException e) {
-				connectionManager.showReconnectDialog("Unsupported Protocol Version", e.getMessage());
+				connectionManager.showReconnectDialog(
+						"Unsupported Protocol Version", e.getMessage());
 				logger.severe(e.getMessage());
 			} catch (UnsupportedSecurityTypeException e) {
-				connectionManager.showReconnectDialog("Unsupported Security Type", e.getMessage());
+				connectionManager.showReconnectDialog(
+						"Unsupported Security Type", e.getMessage());
 				logger.severe(e.getMessage());
 			} catch (AuthenticationFailedException e) {
 				passwordFromParams = null;
-				connectionManager.showReconnectDialog("Authentication Failed", e.getMessage());
+				connectionManager.showReconnectDialog("Authentication Failed",
+						e.getMessage());
 				logger.severe(e.getMessage());
 			} catch (TransportException e) {
-				connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage());
+				connectionManager.showReconnectDialog("Connection Error",
+						"Connection Error" + ": " + e.getMessage());
 				logger.severe(e.getMessage());
 			} catch (IOException e) {
-				connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage());
+				connectionManager.showReconnectDialog("Connection Error",
+						"Connection Error" + ": " + e.getMessage());
 				logger.severe(e.getMessage());
 			} catch (FatalException e) {
-				connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage());
+				connectionManager.showReconnectDialog("Connection Error",
+						"Connection Error" + ": " + e.getMessage());
 				logger.severe(e.getMessage());
 			}
 		}
 	}
-	
+
 	public void createConnectionAndStart() {
 		Thread thread;
 		opendPort = rfb.selectPort(5999);
@@ -198,7 +208,7 @@
 		getCast = new GetBroadCastProxy(this,
 				workingProtocol.getRemoteDesktopName(),
 				this.connectionParams.hostName);
-		thread = new Thread(getCast);		
+		thread = new Thread(getCast);
 		thread.start();
 	}
 
@@ -222,9 +232,9 @@
 				// write later
 			}
 		} else {
-			//getHostData();
+			// getHostData();
 		}
-		//SwingUtilities.invokeLater(myClient);
+		// SwingUtilities.invokeLater(myClient);
 		Thread th = new Thread(vps);
 		th.start();
 		try {
@@ -235,7 +245,6 @@
 		vps.createConnectionAndStart();
 	}
 
-	
 	@Override
 	public void destroy() {
 
@@ -248,63 +257,93 @@
 		}
 		closeApp();
 	}
-	
+
 	private void threadSetAndStart() throws UnknownHostException, IOException {
-		//aClient = new AcceptClient();
+		// aClient = new AcceptClient();
 		createThread = new CreateThread(aClient);
 		Thread thread = new Thread(createThread);
 		thread.start();
 		thread = new Thread(new ChangeHost(this, forceReconnection));
 		thread.start();
-//		createSocketAndSend(aClient.getList(),String.valueOf(port));
+		getChangeScreenRequest();
+		// createSocketAndSend(aClient.getList(),String.valueOf(port));
 	}
-	
+
 	public void setConnectionManager(ConnectionManager _connectionManager) {
 		connectionManager = _connectionManager;
 	}
-	
+
+	private void getChangeScreenRequest() {
+		Thread th = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					Socket clientSocket = null;
+					ServerSocket echoServer = new ServerSocket(10001);
+					while (true) {
+						clientSocket = echoServer.accept();
+						BufferedReader is = new BufferedReader(
+								new InputStreamReader(clientSocket.getInputStream()));
+						String newHostName = is.readLine();
+						// String screenSize = is.readLine();
+						changeVNCServer(newHostName);
+						System.out.println("----------success----------");
+						clientSocket.close();
+					}
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		});
+		th.start();
+	}
+
 	protected void socketClose() {
 		try {
 			workingSocket.close();
-			acceptThread.flag=true;
+			acceptThread.flag = true;
 			getCast.setStopFlag(true);
-			//createThread.setStopFlag(true);
-		} catch (IOException e) {/*nop*/}
+			// createThread.setStopFlag(true);
+		} catch (IOException e) {/* nop */
+		}
 	}
-	
+
 	@Override
 	public void rfbSessionStopped(final String reason) {
 		if (workingSocket != null && workingSocket.isConnected()) {
 			try {
 				workingSocket.close();
-			} catch (IOException e) { /*nop*/ }
+			} catch (IOException e) { /* nop */
+			}
 		}
 	}
-	
-	private void createSocketAndSend(LinkedList<String> clientList,String port) throws UnknownHostException, IOException {
+
+	private void createSocketAndSend(LinkedList<String> clientList, String port)
+			throws UnknownHostException, IOException {
 		boolean passFlag = false;
-		for(String client : clientList) {
-			if(passFlag) {
+		for (String client : clientList) {
+			if (passFlag) {
 				Socket echoSocket;
 				echoSocket = new Socket(client, 10001);
-				DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream());
+				DataOutputStream os = new DataOutputStream(
+						echoSocket.getOutputStream());
 				os.writeBytes("reconnection\n");
-				os.writeBytes(port+"\n");
+				os.writeBytes(port + "\n");
 				os.close();
 			}
 			passFlag = true;
 		}
 	}
 
-	public void changeVNCServer(String hostName) throws UnknownHostException, IOException {
+	public void changeVNCServer(String hostName) throws UnknownHostException,
+			IOException {
 		// sender and reader stop
 		tempWorkingProtocol = workingProtocol;
-		// run call and change workingProtocol 
-		this.connectionParams.hostName = hostName; 
+		// run call and change workingProtocol
+		this.connectionParams.hostName = hostName;
 		this.run();
 		this.createConnectionAndStart();
-		createSocketAndSend(aClient.getList(),String.valueOf(opendPort));
+		createSocketAndSend(aClient.getList(), String.valueOf(opendPort));
 	}
-	
-	
+
 }
--- a/src/viewer_swing/java/com/glavsoft/viewer/TreeConnectionManager.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/TreeConnectionManager.java	Tue Dec 04 17:56:39 2012 +0900
@@ -43,6 +43,7 @@
 			// getBcast.ipRegister();
 			EchoClient echo = new EchoClient(getBcast.textAddress(),9999);
 			rfb.setEcho(echo);
+			rfb.setProxyAddr(getBcast.textAddress());
 			echo.getParentName();
 			connectionParams.hostName = echo.parentAddress;
 			connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); // I should get port number 
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Sun Nov 18 18:47:14 2012 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Tue Dec 04 17:56:39 2012 +0900
@@ -49,6 +49,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.Socket;
+import java.net.UnknownHostException;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.jar.Attributes;
@@ -446,11 +447,14 @@
 		testButton.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				testKey(context);
+				try {
+					rfb.screenChangeRequest();
+				} catch (IOException e1) {
+					e1.printStackTrace();
+				}
 				setSurfaceToHandleKbdFocus();
 			}
 		});		
-
 		
 		
 		
@@ -604,9 +608,6 @@
 		context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, false));
 	}
 	
-	private void testKey(ProtocolContext context) {
-		System.out.println("test");
-	}
 
 	@Override
 	public void windowOpened(WindowEvent e) { /* nop */ }