# HG changeset patch # User one # Date 1354783889 -32400 # Node ID f3b775d3592acbb31ea6234c7c8eaba86879c417 # Parent d2741b80399e9021cf4de11c28831cc391d3ff92 create newVps. diff -r d2741b80399e -r f3b775d3592a .DS_Store Binary file .DS_Store has changed diff -r d2741b80399e -r f3b775d3592a doc/change VNCServer1.asta Binary file doc/change VNCServer1.asta has changed diff -r d2741b80399e -r f3b775d3592a src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Thu Dec 06 17:15:23 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Thu Dec 06 17:51:29 2012 +0900 @@ -55,6 +55,9 @@ public AcceptClient aClient; public int opendPort; + private VncProxyService prevVps; + static VncProxyService currentVps; + // public AcceptClient acc; private void initProxy(Parser parser) { @@ -76,6 +79,20 @@ } + public VncProxyService(VncProxyService vps, String hostName) { + this(); + connectionParams.hostName = hostName; + rfb = vps.rfb; + isClient = vps.isClient; + forceReconnection = vps.forceReconnection; + reconnectionReason = vps.reconnectionReason; + acceptThread = vps.acceptThread; + getCast = vps.getCast; + aClient = vps.aClient; + opendPort = vps.opendPort; + prevVps = vps; + } + public static void main(String[] argv) { String[] mainArgs = argv; System.out.println(mainArgs.length); @@ -118,9 +135,10 @@ private void setArguments(String[] mainArgs) { } + + + public boolean run1() { - @Override - public void run() { rfb = new MyRfbProtoProxy(); // getHostData(); if (forceReconnection) { @@ -166,8 +184,11 @@ updateFrameTitle(); containerFrame.dispose(); containerFrame = null; - if (tempWorkingProtocol != null) - tempWorkingProtocol.cleanUpSession(); + if (prevVps != null) { + prevVps.cleanUpSession(); + prevVps = null; + } + currentVps = this; workingProtocol.startNormalHandling(this, surface, clipboardController, rfb); // rfb.setInitData(workingProtocol.getInitData()); too early @@ -201,6 +222,15 @@ logger.severe(e.getMessage()); } } + return !tryAgain; + } + + private void cleanUpSession() { + if (prevVps != null) { + prevVps.cleanUpSession(); + prevVps = null; + } + workingProtocol.cleanUpSession(); } public void createConnectionAndStart() { @@ -336,12 +366,15 @@ public void changeVNCServer(String hostName) throws UnknownHostException, IOException { // sender and reader stop - tempWorkingProtocol = workingProtocol; + VncProxyService newVps = new VncProxyService(this,hostName); // run call and change workingProtocol - this.connectionParams.hostName = hostName; - this.run(); - this.createConnectionAndStart(); - createSocketAndSend(aClient.getList(), String.valueOf(opendPort)); + newVps.connectionParams.hostName = hostName; + if (newVps.run1()) { + newVps.createConnectionAndStart(); + newVps.createSocketAndSend(aClient.getList(), String.valueOf(opendPort)); + } else { + newVps.cleanUpSession(); + } } } diff -r d2741b80399e -r f3b775d3592a src/viewer_swing/java/com/glavsoft/viewer/Viewer.java --- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Thu Dec 06 17:15:23 2012 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Thu Dec 06 17:51:29 2012 +0900 @@ -236,14 +236,11 @@ workingProtocol.cleanUpSession(); } cleanUpUISessionAndConnection(); - tryAgain = false; if (isApplet) { logger.severe("Applet is stopped."); isAppletStopped = true; repaint(); - } else { - System.exit(0); - } + } } @Override