Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 113:bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 May 2014 23:52:21 +0900 |
parents | 918dc3ee1c79 |
children | 425c45d0da12 |
files | src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 3 files changed, 23 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri May 23 21:48:50 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri May 23 23:52:21 2014 +0900 @@ -109,10 +109,10 @@ public void run() { - byte b[] = new byte[4096]; for (;;) { try { - int c = is.readByte(b); + final byte b[] = new byte[4096]; + final int c = is.readByte(b); if (c <= 0) throw new IOException(); if (isRoot()) { @@ -134,7 +134,14 @@ } } } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { - context.getWriter().write(b); + ClientToServerMessage sc = new ClientToServerMessage() { + @Override + public void send(Writer writer) + throws TransportException { + writer.write(b,0,c); + } + }; + context.sendMessage(sc); } // System.out.println("client read "+c); } catch (Exception e) { @@ -264,10 +271,6 @@ return rfbMinor; } - public void screenChangeRequest() throws TransportException { - String adr = echo.getMyAddress(); - new ScreenChangeRequest(adr).send(context.getWriter()); - } private void sendProxyFlag(Writer writer) throws TransportException { if (proxyFlag) @@ -471,5 +474,9 @@ if (context!=null) context.cleanUpSession(null); } + + public String getMyAddress() { + return echo.getMyAddress(); + } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Fri May 23 21:48:50 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java Fri May 23 23:52:21 2014 +0900 @@ -19,7 +19,7 @@ * length - U8 array - text */ public class ScreenChangeRequest implements ClientToServerMessage { - private final String bytes; + final String bytes; public ScreenChangeRequest(String adr) { this.bytes = adr;
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri May 23 21:48:50 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Fri May 23 23:52:21 2014 +0900 @@ -53,6 +53,8 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Logger; +import jp.ac.u_ryukyu.treevnc.ScreenChangeRequest; + public class SwingViewerWindow implements IChangeSettingsListener { public static final int FS_SCROLLING_ACTIVE_BORDER = 20; private JToggleButton zoomFitButton; @@ -823,18 +825,17 @@ JButton screenButton = buttonsBar.createButton("share", "Share my screen", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - try { - // before change server, data from previous server - // should be stopped. - viewer.setCuiVersion(true); - viewer.getRfb().screenChangeRequest(); - } catch (TransportException e1) { - } + // before change server, data from previous server + // should be stopped. + viewer.setCuiVersion(true); + String adr = viewer.getRfb().getMyAddress(); + context.sendMessage(new ScreenChangeRequest(adr)); } }); kbdButtons.add(screenButton); + ModifierButtonEventListener modifierButtonListener = new ModifierButtonEventListener(); modifierButtonListener.addButton(KeyEvent.VK_CONTROL, ctrlButton); modifierButtonListener.addButton(KeyEvent.VK_ALT, altButton);