# HG changeset patch # User oc # Date 1424672974 -32400 # Node ID 024ac6e457f48a8431783980267ebd8a609c07e4 # Parent 7050b41329c60c523d862f82765e8cd81cf0e783 fix changeVNCServer diff -r 7050b41329c6 -r 024ac6e457f4 src/main/java/com/glavsoft/rfb/encoding/EncodingType.java --- a/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Thu Feb 12 17:01:23 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/EncodingType.java Mon Feb 23 15:29:34 2015 +0900 @@ -70,11 +70,6 @@ CHECK_DELAY(17, "CHECK_DELAY"), /** - * TreeVNC single display width size. - */ - SEND_SINGLE_DISPLAY_SIZE(18, "SEND_SINGLE_DISPLAY_SIZE"), - - /** * share sound. */ SOUND(19, "SOUND"), diff -r 7050b41329c6 -r 024ac6e457f4 src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java --- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Thu Feb 12 17:01:23 2015 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Feb 23 15:29:34 2015 +0900 @@ -283,9 +283,6 @@ int port = rfb.acceptPort; String address = rfb.getMyAddress(); sendCheckDelayReply(rect.time, port, address); - } else if (rect.getEncodingType() == EncodingType.SEND_SINGLE_DISPLAY_SIZE) { - rfb.setSingleDisplaySize(rect.width, rect.height); - // 下に送る } else if (rect.getEncodingType() == EncodingType.SOUND) { // SOUNDを受信した時の処理を } else diff -r 7050b41329c6 -r 024ac6e457f4 src/main/java/jp/ac/u_ryukyu/treevnc/SendSingleDisplaySize.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/SendSingleDisplaySize.java Thu Feb 12 17:01:23 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -package jp.ac.u_ryukyu.treevnc; - -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.glavsoft.rfb.encoding.EncodingType; - -/** - * Created by OcBookPro on 15/01/10. - */ -public class SendSingleDisplaySize { - - private ByteBuffer msg; - private TreeRFBProto rfb; - private int singleDisplayWidth; - - public SendSingleDisplaySize() { - } - - public ByteBuffer singleDisplaySize(int i, int j, int singleDisplayWidth, int height) throws UnsupportedEncodingException { - msg = ByteBuffer.allocate(24).order(ByteOrder.BIG_ENDIAN); - msg.put((byte) 0); // FrameBufferUpdate - msg.put((byte) 0); // padding - msg.putShort((short) 1); // number of rectangle - msg.putShort((short) i); - msg.putShort((short) j); - msg.putShort((short) singleDisplayWidth); - msg.putShort((short) height); - msg.putInt(EncodingType.SEND_SINGLE_DISPLAY_SIZE.getId()); - msg.flip(); - return msg; - } - -} diff -r 7050b41329c6 -r 024ac6e457f4 src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Thu Feb 12 17:01:23 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Mon Feb 23 15:29:34 2015 +0900 @@ -221,11 +221,6 @@ } else { continue; } - } else if (b[0] == ClientToServerMessage.REQUEST_SINGLE_DISPLAY_SIZE) { - ByteBuffer buf = ByteBuffer.wrap(b); - buf.order(ByteOrder.BIG_ENDIAN); - buf.get(); - sendSingleDisplaySize(singleWidth, singleHeight); } else if (b[0] == ClientToServerMessage.READY_SHARE_SOUND) { int rtpPort = selectPort(ConnectionParams.DEFAULT_RTP_PORT); InetAddress hostname = InetAddress.getLocalHost(); @@ -363,15 +358,6 @@ new Thread(sender, "writer-to-lower-node").start(); } - public void sendSingleDisplaySize(int singleDisplayWidth, int singleDisplayHeight) throws UnsupportedEncodingException { - LinkedList linkedListSendSingleDisplaySize = new LinkedList(); - SendSingleDisplaySize sendSingleDisplaySize = new SendSingleDisplaySize(); - linkedListSendSingleDisplaySize.add(sendSingleDisplaySize.singleDisplaySize(0, 0, singleDisplayWidth, singleDisplayHeight)); - addSerialNumber(linkedListSendSingleDisplaySize); - multicastqueue.put(linkedListSendSingleDisplaySize); - System.out.println(singleDisplayWidth + " : send single display width"); - } - public boolean permitChangeScreen() { return permitChangeScreen; } @@ -532,6 +518,8 @@ System.out.println("interrupt wait for vnc connection."); } } + } else { + System.out.println("changeVNCServer : got recconectionId == 0"); } } @@ -818,25 +806,17 @@ * FrameWidth * @param height * FrameHeight - * @param id + * @param newVNCServerId */ - public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, int width, int height, short id) + public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, int width, int height, short newVNCServerId) throws IOException { this.frameSizeWidth = width; this.frameSizeHeight = height; singleWidth = frameSizeWidth; singleHeight = frameSizeHeight; - if (filterSingleDisplay) { - // send single display width to other node. - sendSingleDisplaySize(singleWidth, singleHeight); - } - // if have a parent, send serverChangeRequest to the parent with myAddress and port. - if (this.id == -1) { - context.sendMessage(new ScreenChangeRequest(myAddress, acceptPort, (short) -1, width, height)); - } - if (id == -1) { + if (newVNCServerId == -1) { // change to the tree vnc root on other network. // send whereToConnect. cp = new CreateConnectionParam(this); @@ -846,15 +826,13 @@ return; } // serverChangeの処理 - reconnectingId = id; + reconnectingId = newVNCServerId; vncProxyService.inhelitClients(vncProxyService, hostName); // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary reconnecting = true; // stop reader stop stopReceiverTask(); - if (reconnectingId!=0) { - waitForVNCConnection(); - } + waitForVNCConnection();} } /** diff -r 7050b41329c6 -r 024ac6e457f4 src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java --- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Thu Feb 12 17:01:23 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Mon Feb 23 15:29:34 2015 +0900 @@ -860,17 +860,14 @@ int singleWidth = (int) (rectangles.get(leftScreenNumber).getWidth() * scaleFactor); int singleHeight = (int) (rectangles.get(leftScreenNumber).getHeight() * scaleFactor); viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); - + if (viewer.getRfb().hasParent()) { + String adr = viewer.getRfb().getMyAddress(); + context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, viewer.getRfb().getId(), singleWidth, singleHeight)); + } if (viewer.getRfb().isTreeManager()) { - if (viewer.getRfb().hasParent()) { - String adr = viewer.getRfb().getMyAddress(); - context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, viewer.getRfb().getId(), singleWidth, singleHeight)); - } changeVncServer(viewer, singleWidth, singleHeight, viewer.getRfb().getId()); return; } - String adr = viewer.getRfb().getMyAddress(); - context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_RFB_PORT, viewer.getRfb().getId(), singleWidth, singleHeight)); } }); kbdButtons.add(screenButton); @@ -1022,7 +1019,7 @@ } private void changeVncServer(ViewerInterface viewer, int width, int height, short id) { - String localhost = "127.0.0.1"; + String localhost = "127.0.0.1"; // InetAddress.getLocalHost().getHostName() try { viewer.getRfb().changeVNCServer(viewer, localhost, ConnectionParams.DEFAULT_RFB_PORT, width, height, id); } catch (Exception e1) {