Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 462:b5459c7c8e4d
only one treeManager in a network interface
author | kono |
---|---|
date | Mon, 04 Jul 2016 20:19:31 +0900 |
parents | b7d43b12651c |
children | 5bef0f09f088 |
files | src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java |
diffstat | 2 files changed, 19 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java Mon Jul 04 18:41:14 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java Mon Jul 04 20:19:31 2016 +0900 @@ -8,33 +8,32 @@ public class TreeManagement { + + private final int treeId; public LinkedList<TreeVNCNode> nodeList = new LinkedList<TreeVNCNode>(); boolean runflag = false; private final int treebranch = 2; private boolean showTreeNode = false; private byte[] netmask; private byte[] netaddress; + // node id + // ttttnnnnnnnnnnnn + // tttt 4bit tree number + // nnnnnnnnnnnn 12bit node number + public final int MAX_TREE = 15; + public final int MAX_TREE_NODE = (1<<12)-1; - public TreeManagement(String hostName, int vncport, boolean showTree) { + public TreeManagement(String hostName, int vncport, boolean showTree, int id) { + treeId = id; TreeVNCNode me = new TreeVNCNode(hostName, vncport,"localhost"); showTreeNode = showTree; me.setTreeNum(0); nodeList.add(me); } - // - // private boolean checkAddress(String line) { - // String test[] = line.split("\\."); - // int a = Integer.parseInt(test[0]); - // int b = Integer.parseInt(test[1]); - // if ((192 == a && b == 168) || (172 == a && (b > 15 || b < 32)) - // || 10 == a) { - // return true; - // } else { - // return false; - // } - // } - + public int getTreeId() { + return treeId; + } /** * a parent is lost, remove from the list and move last one into here @@ -162,7 +161,7 @@ public void connectTo(TreeVNCNode newparent, TreeVNCNode n) throws IOException { TreeVncProtocol vc1 = new TreeVncProtocol(n.getHostname(),n.getPort()); - short nodeId = (short) n.getTreeNum(); + short nodeId = (short) ( n.getTreeNum() + ( treeId << 12 )); vc1.connectTo(newparent.getHostname(), newparent.getPort(), isLeader(n), nodeId); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java Mon Jul 04 18:41:14 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java Mon Jul 04 20:19:31 2016 +0900 @@ -26,6 +26,7 @@ } public void getNetworkInterfaces() throws SocketException { + int treeId = 0; for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) { NetworkInterface ni = e.nextElement(); if (ni.isUp() && ni.supportsMulticast() && !ni.isLoopback()) { @@ -35,16 +36,17 @@ if (useHostName) { hostName = ipaddress.getAddress().getHostName(); } - TreeManagement treeManager = new TreeManagement(hostName, ConnectionParams.DEFAULT_VNC_ROOT, myRfb.getViewer().getShowTree()); + TreeManagement treeManager = new TreeManagement(hostName, ConnectionParams.DEFAULT_VNC_ROOT, myRfb.getViewer().getShowTree(),treeId); treeManager.getList().getFirst().setPort(myRfb.getAcceptPort()); byte[] netaddr = ipaddress.getAddress().getAddress(); for(int i=0;i<netaddr.length;i++) { netaddr[i] &= netmask[i]; } treeManager.setNetMask(netmask,netaddr); - addNetworkInterface(ni, treeManager); - System.out.println("Interfaces :" + ni.getName()); + addNetworkInterface(ni, treeManager); // it looks like only last address is used + System.out.println("Interfaces :" + ni.getName() + " treeId=" + treeId + " " + hostName); } + treeId++; } } }