Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 126:775ce6a14f89
find root.
author | oc |
---|---|
date | Fri, 06 Jun 2014 19:17:32 +0900 |
parents | 32c6563492f3 |
children | cc1fcdc7657c |
files | src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java src/main/java/jp/ac/u_ryukyu/treevnc/server/GetBroadCastProxy.java src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java |
diffstat | 7 files changed, 42 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java Fri Jun 06 19:17:32 2014 +0900 @@ -1,6 +1,5 @@ package jp.ac.u_ryukyu.treevnc; import java.net.Socket; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -35,7 +34,7 @@ OutputStream os = newCli.getOutputStream(); InputStream is = newCli.getInputStream(); rfb.newClient(this, newCli, new Writer(os), new Reader(is)); - } catch (IOException e) { + } catch (Exception e) { break; } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Fri Jun 06 19:17:32 2014 +0900 @@ -1,12 +1,10 @@ package jp.ac.u_ryukyu.treevnc; import java.util.logging.Logger; - import com.glavsoft.viewer.ViewerImpl; - +import com.glavsoft.viewer.swing.ConnectionParams; import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol; import jp.ac.u_ryukyu.treevnc.client.GetHostClient; -import jp.ac.u_ryukyu.treevnc.server.GetBroadCastProxy; @@ -21,8 +19,8 @@ logger = Logger.getLogger(getClass().getName()); } - public void communicationToProxy() { - GetHostClient getBcast = new GetHostClient(GetBroadCastProxy.MULTICAST_FIND_TREEVNC_ROOT); + public void findTreeVncRoot() { + GetHostClient getBcast = new GetHostClient(ConnectionParams.DEFAULT_VNC_ROOT_FINDER); getBcast.getHost(); portNumber = 0; do {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Jun 06 19:17:32 2014 +0900 @@ -211,9 +211,6 @@ try { requestThreadNotify(); - - - // after this, we discard upward packet. new Thread(reader, "discard-upward-comm").start(); // writeFramebufferUpdateRequest(0,0, framebufferWidth,
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java Fri Jun 06 19:17:32 2014 +0900 @@ -26,7 +26,7 @@ private ServerSocket server = null; private BufferedReader is; - private int port = ConnectionParams.DEFAULT_VNC_ROOT_FINDER; + private int port; private boolean stopFlag; private TextBoxClient text = new TextBoxClient(); private String proxyAddr; @@ -35,8 +35,8 @@ * To find vnc root, a client sends a multicast packet. * @param _str */ - public GetHostClient(String _str) { - str = _str; + public GetHostClient(int _port) { + port = _port; } public void createSocket() { @@ -76,7 +76,8 @@ public void getHost() { createSocket(); - sendData(); + findRoot(); + // sendData(); } public void findRoot() {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/GetBroadCastProxy.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/GetBroadCastProxy.java Fri Jun 06 19:17:32 2014 +0900 @@ -9,6 +9,9 @@ import java.net.SocketAddress; import java.net.UnknownHostException; +import jp.ac.u_ryukyu.treevnc.client.TreeVncProtocol; + +import com.glavsoft.rfb.protocol.ProtocolContext; import com.glavsoft.viewer.swing.ConnectionParams; //import TextBoxProxy; @@ -43,17 +46,27 @@ soc.joinGroup(mAddr); while (!stopFlag) { soc.receive(recvPacket); - String address = getAddress(recvPacket.getSocketAddress()); +// String address = getAddress(recvPacket.getSocketAddress()); byte[] reply = recvPacket.getData(); int len = recvPacket.getLength(); - int i = 0; - for(byte b : MULTICAST_FIND_TREEVNC_ROOT.getBytes()) { - if (b != reply[i]) return; - i++; - if (i>len) return; + if (len != 12) { + continue; + } + if ((reply[0]&0xff) != ProtocolContext.FIND_ROOT) { + continue; } - int port = parse_code(reply,i,len); - replyToClient(address,port,bCast); + int port = 0; + port = reply[8]; + port = port * 256 + reply[9]; + port = port * 256 + reply[10]; + port = port * 256 + reply[11]; + + TreeVncProtocol t = new TreeVncProtocol("", port); + try { + t.findRootReply(getMyAddress(), vps.getRfb().getAcceptPort()); + } catch (IOException e) { + e.printStackTrace(); + } if(stopFlag) break; } } catch (Exception e) { @@ -85,9 +98,16 @@ final String address = addr; final int port = port_; final String str = str_; - Runnable sender = new Runnable() { + + TreeVncProtocol t = new TreeVncProtocol("", port_); + try { + t.findRootReply(str_, port_); + } catch (IOException e) { + e.printStackTrace(); + } + + Runnable sender = new Runnable() { public void run() { - try { Thread.sleep(1000); Socket socket = new Socket(address, port); // This is a TCP stream to reply @@ -103,6 +123,7 @@ } } }; + new Thread(sender).start(); }
--- a/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Fri Jun 06 19:17:32 2014 +0900 @@ -214,7 +214,7 @@ CuiViewer viewer = new CuiViewer(); MyRfbProtoClient rfb = new MyRfbProtoClient(); CreateConnectionParam cp = new CreateConnectionParam(rfb); - cp.communicationToProxy(); + cp.findTreeVncRoot(); cp.createConnectionParam(viewer); rfb.setViewer(viewer); viewer.myRfb = rfb;
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Thu Jun 05 18:30:45 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Fri Jun 06 19:17:32 2014 +0900 @@ -291,7 +291,7 @@ public void startViewer() { MyRfbProtoClient rfb = new MyRfbProtoClient(); CreateConnectionParam cp = new CreateConnectionParam(rfb); - cp.communicationToProxy(); + cp.findTreeVncRoot(); cp.createConnectionParam(this); isTreeVNC = true; rfb.setViewer(this);