# HG changeset patch # User oc # Date 1401955294 -32400 # Node ID 214d4f2064312539b117119b4ab90aa1af7718c5 # Parent 233e94a7b5ed68493e6a94a2130b19c4db0788ab add TreeVNC command number. diff -r 233e94a7b5ed -r 214d4f206431 src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java --- a/src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java Tue May 27 00:12:55 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ProtocolContext.java Thu Jun 05 17:01:34 2014 +0900 @@ -75,5 +75,20 @@ void resetDecoder(); void stopReceiverTask(); + + /** + * TreeVNC expension command (server to client) + * 0 : command byte + * 1-3 : padding + * 4 : length U32 + * length : text + * + */ + public static final int FIND_ROOT = 220; + public static final int FIND_ROOT_REPLY = 221; + public static final int WHERE_TO_CONNECT = 222; + public static final int CONNECT_TO = 223; + public static final int LOST_PARENT = 224; + } diff -r 233e94a7b5ed -r 214d4f206431 src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Tue May 27 00:12:55 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Thu Jun 05 17:01:34 2014 +0900 @@ -1,6 +1,7 @@ package jp.ac.u_ryukyu.treevnc; import java.io.IOException; + import java.io.OutputStream; import java.net.BindException; import java.net.ServerSocket; @@ -26,6 +27,7 @@ import com.glavsoft.transport.Writer; import com.glavsoft.viewer.ViewerImpl; + public abstract class MyRfbProto { final static int FramebufferUpdateRequest = 3; final static int CheckDelay = 11; @@ -61,11 +63,43 @@ abstract public boolean isRoot() ; + public boolean initialConnection(final Writer os, final Reader is) + throws IOException, TransportException { + /** + * initial connection of RFB protocol + */ + sendRfbVersion(os); + byte[] b; + if ((b = readVersionMsg(is, os))!=null) { + treeVncCommand(b,is,os); + return true; + } + sendSecurityType(os); + readSecType(is); + sendSecResult(os); + readClientInit(is); + sendInitData(os); + return false; + } + + private void treeVncCommand(byte[] b, Reader is, Writer os) { + ByteBuffer buf = ByteBuffer.wrap(b); + int command = buf.get(); + + switch (command) { + case ProtocolContext.FIND_ROOT : + case ProtocolContext.WHERE_TO_CONNECT : + case ProtocolContext.LOST_PARENT : + System.out.println("get treeVNC command" + command); + } + } + public void newClient(AcceptThread acceptThread, final Socket newCli, - final Writer os, final Reader is) throws IOException { - // createBimgFlag = true; - // rfb.addSockTmp(newCli); - // addSock(newCli); + final Writer os, final Reader is) throws IOException, TransportException { + + + if (initialConnection(os, is)) return; // + final int myId = clients; final MulticastQueue.Client> c = multicastqueue.newClient(); final AtomicInteger writerRunning = new AtomicInteger(); @@ -177,17 +211,9 @@ try { requestThreadNotify(); - /** - * initial connection of RFB protocol - */ - sendRfbVersion(os); - // readVersionMsg(is); - readVersionMsg(is, os); - sendSecurityType(os); - readSecType(is); - sendSecResult(os); - readClientInit(is); - sendInitData(os); + + + // after this, we discard upward packet. new Thread(reader, "discard-upward-comm").start(); // writeFramebufferUpdateRequest(0,0, framebufferWidth, @@ -255,12 +281,13 @@ writer.write(versionMsg_3_856.getBytes()); } - private int readVersionMsg(Reader reader, Writer writer) throws IOException, TransportException { + private byte[] readVersionMsg(Reader reader, Writer writer) throws IOException, TransportException { byte[] b = new byte[12]; reader.readBytes(b); + if (b[0]>=220) return b; // TreeVNC extention command. if ((b[0] != 'R') || (b[1] != 'F') || (b[2] != 'B') || (b[3] != ' ') || (b[4] < '0') || (b[4] > '9') || (b[5] < '0') || (b[5] > '9') || (b[6] < '0') || (b[6] > '9') || (b[7] != '.') @@ -282,7 +309,7 @@ if (proxyFlag) sendPortNumber(writer); } - return rfbMinor; + return null; } @@ -677,4 +704,6 @@ // But we have do inflation for all input data, so we have to do it // here. } + + } diff -r 233e94a7b5ed -r 214d4f206431 src/viewer_swing/java/com/glavsoft/viewer/swing/ConnectionParams.java --- a/src/viewer_swing/java/com/glavsoft/viewer/swing/ConnectionParams.java Tue May 27 00:12:55 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/ConnectionParams.java Thu Jun 05 17:01:34 2014 +0900 @@ -33,7 +33,7 @@ public class ConnectionParams implements Model { public static final int DEFAULT_SSH_PORT = 22; public static final int DEFAULT_RFB_PORT = 5900; - public static final int DEFAULT_VNC_ROOT_FINDER = 8182; + public static final int DEFAULT_VNC_ROOT_FINDER = DEFAULT_RFB_PORT; public String hostName; private int portNumber;