diff src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 232:6ee4cdca104c

send value of port and localhost in checkdelay framebufferupdate, and get this.
author oc
date Fri, 10 Oct 2014 23:39:44 +0900
parents 0e0e6744432c
children 26b7c0a6d91b
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Wed Oct 08 17:44:39 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Fri Oct 10 23:39:44 2014 +0900
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.BindException;
 import java.net.NetworkInterface;
 import java.net.ServerSocket;
@@ -9,6 +10,7 @@
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.zip.DataFormatException;
@@ -169,6 +171,7 @@
                             } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) {
                                 ByteBuffer buf = ByteBuffer.wrap(b);
                                 buf.order(ByteOrder.BIG_ENDIAN);
+//                                getNodeNum(port, hostname, localhostname);
                                 Long time = buf.getLong(2);
                                 Long delay = System.currentTimeMillis() - time;
                                 System.out.println("delay = " + delay);
@@ -545,9 +548,10 @@
      * @param dataLen
      * @param reader
      * @throws TransportException
+     * @throws UnsupportedEncodingException 
      */
     public void readSendData(int dataLen, Reader reader, byte[] bytes)
-            throws TransportException {
+            throws TransportException, UnsupportedEncodingException {
         LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>();
         ByteBuffer header = multicastqueue.allocate(16);
         ByteBuffer serial = multicastqueue.allocate(8);
@@ -565,7 +569,10 @@
             if (i%20 == 0) {
                 LinkedList<ByteBuffer> checkdelay = new LinkedList<ByteBuffer>();
                 long time = System.currentTimeMillis();
-                checkdelay.add(new UpdateRectangleMessage(0, 0, 0, 0, time, EncodingType.CHECK_DELAY).getMessage());
+                int port = 1234;
+                String localhost = "133.13.11.9";
+                String mylocalhost = "localhost";
+                checkdelay.add(new UpdateRectangleMessage(0, 0, 0, 0, time, port, localhost, EncodingType.CHECK_DELAY).getMessage());
                 this.addSerialNumber(checkdelay);
                 multicastqueue.put(checkdelay);
               } i++;
@@ -743,9 +750,21 @@
         return reconnectingId;
     }
 
-
     public void setShowTree(boolean showTree) {
         showTreeNode  = showTree;
     }
 
+    public int getNodeNum(int port, String hostname, String localhostname) {
+        int nodeNum = 0;
+        
+        
+
+        for (Iterator<TreeVNCNode> i = nodeList.iterator(); i.hasNext();) {
+            TreeVNCNode tvn = (TreeVNCNode)i.next();
+            System.out.println("port = " + tvn.port + ", hostname = " + tvn.hostname + ", localhostname = " + tvn.localhostname + ", nodeNumber" + tvn.treeNum);
+        }
+        
+        return nodeNum;
+        
+    }
 }