Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 339:4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
author | oc |
---|---|
date | Fri, 06 Feb 2015 19:06:50 +0900 (2015-02-06) |
parents | 931e1abda61d |
children | fd529c51095f |
files | .idea/gradle.xml src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 7 files changed, 30 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/.idea/gradle.xml Fri Feb 06 16:36:12 2015 +0900 +++ b/.idea/gradle.xml Fri Feb 06 19:06:50 2015 +0900 @@ -5,7 +5,7 @@ <GradleProjectSettings> <option name="distributionType" value="LOCAL" /> <option name="externalProjectPath" value="$PROJECT_DIR$" /> - <option name="gradleHome" value="/usr/local/Cellar/gradle/2.1/libexec" /> + <option name="gradleHome" value="/usr/local/share/gradle" /> <option name="modules"> <set> <option value="$PROJECT_DIR$" />
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Feb 06 16:36:12 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Feb 06 19:06:50 2015 +0900 @@ -96,7 +96,6 @@ fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); } if(rfb.isTreeManager()) { - // これを定期的にフルサイズのframebufferUpdateを送信するThreadにしよう! fullscreenFbUpdateIncrementalRequest.sendFullScreenRequest(); connectionFinished(); if(rfb.checkDelay) {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Fri Feb 06 16:36:12 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Fri Feb 06 19:06:50 2015 +0900 @@ -8,13 +8,11 @@ import com.glavsoft.transport.Writer; /** - * ClientCutText - * The client has new ISO 8859-1 (Latin-1) text in its cut buffer. Ends of lines are repre- - * sented by the linefeed / newline character (value 10) alone. No carriage-return (value - * 13) is needed. There is currently no way to transfer text outside the Latin-1 character - * set. - * 1 - U8 - 6 + * ServerChangeRequest + * Change VNCServer + * 1 - U8 - 240 * 3 - - padding + * 4 - - id * 4 - U32 - length * length - U8 array - text */
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Feb 06 16:36:12 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Fri Feb 06 19:06:50 2015 +0900 @@ -42,7 +42,7 @@ private Inflater inflater = new Inflater(); private Deflater deflater = new Deflater(); ViewerInterface viewer; - private short id; // my tree node id ( = 0 in root ) + private short id = -1; // my tree node id ( = 0 in root ), -1 means no parent private TreeVncCommandChannelListener acceptThread; private TreeRootFinderListener getCast; private CreateConnectionParam cp; @@ -51,7 +51,6 @@ private TreeVncRootSelectionPanel rootSelectionPanel; private String vncInterface; public LinkedList<TreeVNCNode> nodeList; - public TreeRFBProto rfb; protected boolean readyReconnect = false; private boolean cuiVersion; @@ -84,7 +83,6 @@ nets.setMyRfb(this); this.isTreeManager = isTreeManager; this.viewer = viewer; - this.rfb = this; // this.socket = createSocket(); if(isTreeManager()) { getCast = new TreeRootFinderListener(viewer); @@ -218,9 +216,8 @@ int frameSizeWidth = buf.getInt(); int frameSizeHeight = buf.getInt(); System.out.println("Root server change request :" + newHostName); - // please remove these numbers. + changeVNCServer(viewer, newHostName, frameSizeWidth, frameSizeHeight, id); if (viewer != null) { - changeVNCServer(viewer, newHostName, frameSizeWidth, frameSizeHeight, id); viewer.setFitScreen(); } } else { @@ -232,7 +229,6 @@ buf.get(); sendSingleDisplaySize(singleWidth, singleHeight); } else if (b[0] == ClientToServerMessage.READY_SHARE_SOUND) { - System.out.println("rootは受信準備を始める。"); int rtpPort = selectPort(ConnectionParams.DEFAULT_RTP_PORT); InetAddress hostname = InetAddress.getLocalHost(); ReceiveSound receiveSound = new ReceiveSound(socket); @@ -809,6 +805,18 @@ // send single display width to other node. sendSingleDisplaySize(singleWidth, singleHeight); } + // if have a parent, send serverChangeRequest to the parent with myAddress and port. + if (hasParent()) + context.sendMessage(new ScreenChangeRequest(myAddress, (short) -1, width, height)); + if (id == -1) { + // change to the tree vnc root on other network. + // send whereToConnect. + cp = new CreateConnectionParam(this); + cp.setHostName(hostName, ConnectionParams.DEFAULT_VNC_ROOT, myAddress); + cp.sendWhereToConnect(viewer); + stopReceiverTask(); + return; + } reconnectingId = id; vncProxyService.inhelitClients(vncProxyService, hostName); // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary @@ -821,23 +829,6 @@ } /** - * Create send sound thread. - */ - public void createSendSoundThread(TreeRFBProto rfb) throws SocketException, UnknownHostException { - SendSound sendSound; -// DatagramSocket socket = new DatagramSocket(selectPort(ConnectionParams.DEFAULT_RTP_PORT), InetAddress.getLocalHost()); - if(rfb.isTreeManager()) { - sendSound = new SendSound(socket, rfb); - } else { - String ip = "133.13.57.59"; - String port = "60004"; - sendSound = new SendSound(socket, rfb, ip, port); - } - Thread sendSoundThread = new Thread(sendSound, "send-sound"); - sendSoundThread.start(); - } - - /** * start accepting children * run rootFinderListener if necessary */ @@ -939,4 +930,8 @@ public int getSingleHeight() { return singleHeight; } + + public boolean hasParent() { + return id != -1; + } } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java Fri Feb 06 16:36:12 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncCommand.java Fri Feb 06 19:06:50 2015 +0900 @@ -91,19 +91,20 @@ } /** - * set new parent address + * Connect to parent. * @param port * @param hostname * @param leader * @param id * @throws IOException * @throws SocketException - * @throws UnknownHostException + * @throws UnknownHostException + * + * Even if this is a tree root, + * connect to the node anyway. + * This enables internet wide connection. */ void handleConnectTo(int port, String hostname, String myHostName, boolean leader, short id) { - if (rfb.isTreeManager()) { - return; // we don't have parent - } rfb.stopReceiverTask(); rfb.setId(id); rfb.setMyAddress(myHostName);
--- a/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Fri Feb 06 16:36:12 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java Fri Feb 06 19:06:50 2015 +0900 @@ -123,6 +123,7 @@ i++; } else if ("--host".equals(args[i])) { hostName = args[++i]; + treeProxy = true; } else if ("--showTree".equals(args[i])) { // show Tree node. showTree = true;
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Feb 06 16:36:12 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri Feb 06 19:06:50 2015 +0900 @@ -936,14 +936,6 @@ uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, singleWidth, singleHeight); } - private void shareSound(boolean isTreeManager, ProtocolContext context) throws SocketException, UnknownHostException { - viewer.getRfb().createSendSoundThread(viewer.getRfb()); - if (!isTreeManager) { - context.sendMessage(new ReadyShareSound()); - return; - } - } - private void sendCtrlAltDel(ProtocolContext context) { context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, true)); context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, true));