changeset 629:710c26fd3ebe

fix send lost parent state to root
author ryokka
date Sun, 22 Mar 2020 20:04:21 +0900
parents c67f0f6eae90
children 7071b01621c2
files Todo.txt src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java
diffstat 4 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Todo.txt	Sun Mar 22 19:17:07 2020 +0900
+++ b/Todo.txt	Sun Mar 22 20:04:21 2020 +0900
@@ -1,3 +1,9 @@
+Sun Mar 22 19:18:07 JST 2020
+    connect to は Viewer にある
+    接続に失敗したら lost parent を実行する
+    parent が生きてても lost parent を尊重する方向でいく
+
+
 Mon Mar  9 18:29:02 JST 2020
 
     Broadcast で統一する
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java	Sun Mar 22 19:17:07 2020 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java	Sun Mar 22 20:04:21 2020 +0900
@@ -88,7 +88,10 @@
      */
     public void fixLostParent(String hostname, int port, String myHostName) {
         TreeVNCNode lostParentNode = lookup(nodeList,hostname,port);
-        if (lostParentNode == null ) return;   // something wrong
+        if (lostParentNode == null ) {
+            // add list and reconfiguration necessary
+            return;   // something wrong
+        }
         int treeNumber = lostParentNode.getTreeNum();
         TreeVNCNode deadParent = getParentNode(treeNumber);
         TreeVNCNode me = nodeList.getFirst();
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Sun Mar 22 19:17:07 2020 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Sun Mar 22 20:04:21 2020 +0900
@@ -167,12 +167,7 @@
                                 int myHostPort = 0;
                                 clients = myId;
                                 if (!isTreeManager) {
-                                    rootHostName = getConnectionParam().getHostName();
-                                    rootHostPort = getConnectionParam().getPort();
-                                    myHostName = getMyAddress();
-                                    myHostPort = getAcceptPort();
-                                    TreeVncProtocol echo = new TreeVncProtocol(rootHostName, rootHostPort);
-                                    echo.lostChild(myHostName, myHostPort, myId);
+                                    sendLostChild(myId);
                                 } else {
                                     getTreeManager(intf).fixLostChild1(myId + 1);
                                 }
@@ -358,6 +353,33 @@
         new Thread(sender, "writer-to-lower-node").start();
     }
 
+    private void sendLostChild(int myId) {
+        String rootHostName;
+        int rootHostPort;
+        String myHostName;
+        int myHostPort;
+        rootHostName = getConnectionParam().getHostName();
+        rootHostPort = getConnectionParam().getPort();
+        myHostName = getMyAddress();
+        myHostPort = getAcceptPort();
+        TreeVncProtocol echo = new TreeVncProtocol(rootHostName, rootHostPort);
+        echo.lostChild(myHostName, myHostPort, myId);
+    }
+
+    public void sendLostParent() {
+        String rootHostName;
+        int rootHostPort;
+        String myHostName;
+        int myHostPort;
+        rootHostName = getConnectionParam().getHostName();
+        rootHostPort = getConnectionParam().getPort();
+        myHostName = getMyAddress();
+        myHostPort = getAcceptPort();
+        TreeVncProtocol echo = new TreeVncProtocol(rootHostName, rootHostPort);
+        echo.lostParent(myHostName, myHostPort);
+    }
+
+
     public boolean permitChangeScreen() {
         return permitChangeScreen;
     }
--- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java	Sun Mar 22 19:17:07 2020 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java	Sun Mar 22 20:04:21 2020 +0900
@@ -181,7 +181,13 @@
 
     public void connectionFailed() {
         cancelConnection();
-        if (isTreeVNC) return;
+        if (isTreeVNC) {
+            // send lost parent to root
+            if (viewer != null && viewer.getRfb() != null){
+                viewer.getRfb().sendLostParent();
+            }
+            return;
+        }
         if (allowInteractive) {
             enableConnectionDialog();
         } else {