Mercurial > hg > Applications > TightVNC_orginal
changeset 39:6a34a5220a01
add files
author | one |
---|---|
date | Tue, 02 Oct 2012 18:13:13 +0900 |
parents | c2f0b6907448 |
children | 3c072f2f39bb |
files | src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java src/main/java/jp/ac/u_ryukyu/treevnc/server/ChangeHost.java src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ChangeHost.java src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ReconnectionRequest.java src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ScreenChanges.java src/viewer_swing/java/com/glavsoft/viewer/ConnectionManager.java |
diffstat | 6 files changed, 159 insertions(+), 112 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java Thu Sep 27 19:32:25 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java Tue Oct 02 18:13:13 2012 +0900 @@ -36,7 +36,7 @@ if(flag) throw new IOException(); OutputStream os = newCli.getOutputStream(); InputStream is = newCli.getInputStream(); - if(confirmHalt(is)) break; +// if(confirmHalt(is)) break; rfb.newClient(this, newCli, new Writer(os), new Reader(is)); } catch (IOException e) { break;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/ChangeHost.java Thu Sep 27 19:32:25 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -package jp.ac.u_ryukyu.treevnc.server; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.LinkedList; - -import jp.ac.u_ryukyu.treevnc.MyRfbProto; - -import com.glavsoft.rfb.protocol.ProtocolSettings; -import com.glavsoft.viewer.ConnectionManager; -import com.glavsoft.viewer.Viewer; -import com.glavsoft.viewer.swing.ParametersHandler; - -public class ChangeHost extends ConnectionManager implements Runnable { - - private VncProxyService vps; - private VncProxyService prevVps; - private LinkedList<String> clientList; - private int port; - - public ChangeHost(VncProxyService _vps, boolean isApplet, - VncProxyService _prevVps) { - super(_vps, isApplet); - vps = _vps; - prevVps = _prevVps; - } - - /** - * - */ - private static final long serialVersionUID = 1L; - String str; - - @Override - public void run() { - try { - BufferedReader br = new BufferedReader(new InputStreamReader( - System.in)); - str = br.readLine(); - vps.changeVNCServer(); - vps.setConnectionManager(this); - Thread thread = new Thread(vps); - thread.start(); - Thread.sleep(1000); - vps.createConnectionAndStart(); - prevVps.socketClose(); - vps.aClient.setList(prevVps.aClient.getList()); -// clientList = prevVps.aClient.getList(); -// createSocketAndSend(clientList,String.valueOf(port)); - System.out.println(str); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - String getHost() { - return str; - } - - @Override - public Socket connectToHost( - final ParametersHandler.ConnectionParams connectionParams, - ProtocolSettings settings, MyRfbProto rfb) { - Socket socket = null; - connectionParams.hostName = str; - connectionParams.portNumber = 5900; - Viewer.logger.info("Connecting to host " + connectionParams.hostName - + ":" + connectionParams.portNumber); - try { - socket = new Socket(connectionParams.hostName, - connectionParams.portNumber); - } catch (UnknownHostException e) { - Viewer.logger.severe("Unknown host: " + connectionParams.hostName); - showConnectionErrorDialog("Unknown host: '" - + connectionParams.hostName + "'"); - } catch (IOException e) { - Viewer.logger.severe("Couldn't connect to: " - + connectionParams.hostName + ":" - + connectionParams.portNumber + ": " + e.getMessage()); - showConnectionErrorDialog("Couldn't connect to: '" - + connectionParams.hostName + "'\n" + e.getMessage()); - } - return socket; - } - - private void createSocketAndSend(LinkedList<String> clientList,String port) throws UnknownHostException, IOException { - int i = 0; - for(String client : clientList) { - if(i!=0) { - Socket echoSocket; - echoSocket = new Socket(client, 10001); - DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream()); - os.writeBytes("reconnection\n"); - os.writeBytes(port+"\n"); - os.close(); - } - i++; - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ChangeHost.java Tue Oct 02 18:13:13 2012 +0900 @@ -0,0 +1,106 @@ +package jp.ac.u_ryukyu.treevnc.server.state; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.LinkedList; + +import jp.ac.u_ryukyu.treevnc.MyRfbProto; +import jp.ac.u_ryukyu.treevnc.server.VncProxyService; + +import com.glavsoft.rfb.protocol.ProtocolSettings; +import com.glavsoft.viewer.ConnectionManager; +import com.glavsoft.viewer.Viewer; +import com.glavsoft.viewer.swing.ParametersHandler; + +public class ChangeHost extends ConnectionManager implements Runnable,ScreenChanges { + + private VncProxyService vps; + private ScreenChanges screenChange; + private LinkedList<String> clientList; + private int port; + + + public ChangeHost(VncProxyService _vps, boolean isApplet) { + super(_vps, isApplet); + vps = _vps; + screenChange = this; + } + + + /** + * + */ + private static final long serialVersionUID = 1L; + String str; + + @Override + public void run() { + try { + while(screenChange.next()); + } catch (UnknownHostException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public String getHost() { + return str; + } + + private void waitingInput() { + try { + BufferedReader br = new BufferedReader(new InputStreamReader( + System.in)); + str = br.readLine(); + vps.changeVNCServer(); +// vps.createConnectionAndStart(); +// vps.aClient.setList(prevVps.aClient.getList()); +// clientList = prevVps.aClient.getList(); +// createSocketAndSend(clientList,String.valueOf(port)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public Socket connectToHost( + final ParametersHandler.ConnectionParams connectionParams, + ProtocolSettings settings, MyRfbProto rfb) { + Socket socket = null; + connectionParams.hostName = str; + connectionParams.portNumber = 5900; + Viewer.logger.info("Connecting to host " + connectionParams.hostName + + ":" + connectionParams.portNumber); + try { + socket = new Socket(connectionParams.hostName, + connectionParams.portNumber); + } catch (UnknownHostException e) { + Viewer.logger.severe("Unknown host: " + connectionParams.hostName); + showConnectionErrorDialog("Unknown host: '" + + connectionParams.hostName + "'"); + } catch (IOException e) { + Viewer.logger.severe("Couldn't connect to: " + + connectionParams.hostName + ":" + + connectionParams.portNumber + ": " + e.getMessage()); + showConnectionErrorDialog("Couldn't connect to: '" + + connectionParams.hostName + "'\n" + e.getMessage()); + } + return socket; + } + + + @Override + public boolean next() { + waitingInput(); + changeState(new ReconnectionRequest(vps)); + return true; + } + + public void changeState(ScreenChanges change) { + screenChange = change; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ReconnectionRequest.java Tue Oct 02 18:13:13 2012 +0900 @@ -0,0 +1,38 @@ +package jp.ac.u_ryukyu.treevnc.server.state; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; + +import jp.ac.u_ryukyu.treevnc.server.VncProxyService; + +public class ReconnectionRequest implements ScreenChanges { + private VncProxyService vps; + + public ReconnectionRequest(VncProxyService vps) { + this.vps = vps; + } + + @Override + public boolean next() throws UnknownHostException, IOException { + createSocketAndSend(String.valueOf(vps.opendPort)); + return false; + } + + private void createSocketAndSend(String port) throws UnknownHostException, IOException { + int i = 0; + for(String client : vps.aClient.getList()) { + if(i!=0) { + Socket echoSocket; + echoSocket = new Socket(client, 10001); + DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream()); + os.writeBytes("reconnection\n"); + os.writeBytes(port+"\n"); + os.close(); + } + i++; + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ScreenChanges.java Tue Oct 02 18:13:13 2012 +0900 @@ -0,0 +1,10 @@ +package jp.ac.u_ryukyu.treevnc.server.state; + +import java.io.IOException; +import java.net.UnknownHostException; + +public interface ScreenChanges { + + boolean next() throws UnknownHostException, IOException; + +}
--- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionManager.java Thu Sep 27 19:32:25 2012 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionManager.java Tue Oct 02 18:13:13 2012 +0900 @@ -139,7 +139,7 @@ connectionParams.portNumber = connectionDialog.getPort(); } */ - connectionParams.hostName = "localhost"; +// connectionParams.hostName = "localhost"; connectionParams.portNumber = 5900; Viewer.logger.info("Connecting to host " + connectionParams.hostName + ":" + connectionParams.portNumber); try { @@ -158,9 +158,9 @@ wasError = true; } } while (!isApplet && (connectionParams.isHostNameEmpty() || wasError)); - if (connectionDialog != null) { - connectionDialog.dispose(); - } +// if (connectionDialog != null) { +// connectionDialog.dispose(); +// } return socket; }