Mercurial > hg > Applications > TightVNC_orginal
changeset 42:fe38611c4b2b
change the location of the call cleanUpSession().
author | one |
---|---|
date | Thu, 25 Oct 2012 19:38:20 +0900 |
parents | 0f260079879f |
children | 6687aa9dd55e |
files | dist/tightvnc-jviewer-2.5.0/tightvnc-jviewer.jar src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java |
diffstat | 7 files changed, 26 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Oct 22 17:51:02 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Thu Oct 25 19:38:20 2012 +0900 @@ -122,13 +122,12 @@ if(rfb instanceof MyRfbProtoClient) { System.out.println("task stop"); int counter = 0; + EchoClient echo = rfb.getEcho(); + echo.openport(); while(true) { - EchoClient echo = rfb.getEcho(); if(counter > 3) { - echo.openport(); echo.notfoundParent(); } - echo.openport(); if(echo.lostHost()) break; counter++; }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java Mon Oct 22 17:51:02 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java Thu Oct 25 19:38:20 2012 +0900 @@ -20,52 +20,17 @@ public String treeNum; public String leaderFlag; - - public EchoClient() { - } - - public EchoClient(EchoClient echo) { - this.name = echo.name; - this.leaderFlag = echo.leaderFlag; - this.parentNum = echo.parentNum; - this.treeNum = echo.treeNum; - this.client = echo.client; - this.waitReply = echo.waitReply; - // checkMove = (MyVncClient)echo.client; - } - - public EchoClient(String name, MyVncClient client) { - this.client = client; - this.name = name; - } - public EchoClient(String name, int echoPort) { this.echoPort = echoPort; this.name = name; } - public EchoClient(String name, MyVncClient client, int echoPort) { - this.client = client; - this.name = name; - this.echoPort = echoPort; - } - - public EchoClient(EchoClient echo, MyVncClient client) { - this.client = client; - this.name = echo.name; - leaderFlag = echo.leaderFlag; - parentNum = echo.parentNum; - treeNum = echo.treeNum; - waitReply = echo.waitReply; - } public void openport() { try { - if (name != null) { - echoSocket = new Socket(name, echoPort); - } else { - echoSocket = new Socket("133.13.48.18", echoPort); - } + //if(echoSocket==null) + echoSocket = new Socket(name, echoPort); + echoSocket.setReuseAddress(true); os = new DataOutputStream(echoSocket.getOutputStream()); is = new BufferedReader(new InputStreamReader( echoSocket.getInputStream())); @@ -207,12 +172,9 @@ try { client.close(); client.setSocket(createSocketForClient(echoSocket)); - Thread.sleep(1000); client.run(); } catch (IOException e) { e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); } } @@ -254,7 +216,7 @@ if (clientSocket == null) { // echo = new EchoClient(pHost, this); openport(); - requestHostName("1"); + requestHostName("1"); // 1 is normal connection type. } else { Interruption(clientSocket); } @@ -270,7 +232,7 @@ String tempParentAddress = is.readLine(); parentNum = is.readLine(); if("reconnection".equals(tempParentAddress)) { - System.out.println("into function \n" + parentNum); + System.out.println("-----------------into function \n" + parentNum); return new Socket(parentAddress,Integer.parseInt(parentNum)); } treeNum = is.readLine();
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java Mon Oct 22 17:51:02 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/MyRfbProtoClient.java Thu Oct 25 19:38:20 2012 +0900 @@ -70,11 +70,6 @@ return value; } - Socket changeParent(String host, int port) throws IOException { - sock = new Socket(host, port); - return sock; - } - @Override public Socket accept() throws IOException { return servSock.accept();
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java Mon Oct 22 17:51:02 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java Thu Oct 25 19:38:20 2012 +0900 @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.net.BindException; import java.net.ServerSocket; import java.net.Socket; @@ -29,17 +30,21 @@ echoServer = new ServerSocket(10001); clientSocket = echoServer.accept(); if (clientSocket != null) { + echo.client.stopTask(); echo.client.close(); passflag = true; + System.out.println("------waitreply"); echo.client.setSocket(echo.createSocketForClient(clientSocket)); // hult(); // client.init(); echo.client.run(); echoServer.close(); } + } catch (BindException e) { + break; } catch (IOException e) { System.out.println(e); - } + } } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Mon Oct 22 17:51:02 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Thu Oct 25 19:38:20 2012 +0900 @@ -75,6 +75,8 @@ private final UiSettings uiSettings; private AcceptThread acceptThread; private GetBroadCastProxy getCast; + + private Protocol tempWorkingProtocol; public static void main(String[] argv) { @@ -159,6 +161,8 @@ containerFrame.dispose(); containerFrame = null; workingProtocol.startNormalHandling(this, surface, clipboardController,rfb); + if(tempWorkingProtocol!=null) + tempWorkingProtocol.cleanUpSession(); // rfb.setInitData(workingProtocol.getInitData()); too early // workingProtocol.startNormalHandling(this, surface, clipboardController); tryAgain = false; @@ -283,9 +287,9 @@ } private void createSocketAndSend(LinkedList<String> clientList,String port) throws UnknownHostException, IOException { - int i = 0; + boolean passFlag = false; for(String client : clientList) { - if(i!=0) { + if(passFlag) { Socket echoSocket; echoSocket = new Socket(client, 10001); DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream()); @@ -293,13 +297,13 @@ os.writeBytes(port+"\n"); os.close(); } - i++; + passFlag = true; } } public void changeVNCServer(String hostName) throws UnknownHostException, IOException { - // sender and reader - workingProtocol.cleanUpSession(); + // sender and reader stop + tempWorkingProtocol = workingProtocol; // run call and change workingProtocol this.connectionParams.hostName = hostName; this.run();
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Mon Oct 22 17:51:02 2012 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Thu Oct 25 19:38:20 2012 +0900 @@ -296,7 +296,7 @@ break; } logger.info("Connected"); - + System.out.println("-------------"+connectionParams.hostName); try { workingSocket.setTcpNoDelay(true); // disable Nagle algorithm Reader reader = new Reader(workingSocket.getInputStream()); @@ -684,4 +684,7 @@ return connectionParams.portNumber; } + public void stopTask() { + workingProtocol.cleanUpSession(); + } }