Mercurial > hg > Applications > TreeVNC
changeset 202:22676ca0dd97
get VNC Socket.
author | oc |
---|---|
date | Fri, 27 Jun 2014 19:21:18 +0900 |
parents | ced24de3f2c5 |
children | 2f6237fea67e |
files | src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java src/viewer_swing/java/com/glavsoft/viewer/RfbConnectionWorker.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java |
diffstat | 8 files changed, 47 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Fri Jun 27 19:21:18 2014 +0900 @@ -287,7 +287,7 @@ } private void connectionFinished() { - rfb.setReadyReconnect(true); + rfb.vncConnected(true); } private void getLost(Reader reader) throws Exception {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Fri Jun 27 19:21:18 2014 +0900 @@ -72,7 +72,7 @@ rThread = new RequestScreenThread(this); } - abstract public boolean isRoot() ; + abstract public boolean isTreeManager() ; public ProtocolContext getContext() { return context; @@ -148,7 +148,7 @@ final int c = is.readByte(b); if (c <= 0) throw new IOException(); - if (isRoot()) { + if (isTreeManager()) { if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { if (permitChangeScreen()) { ByteBuffer buf = ByteBuffer.wrap(b); @@ -357,8 +357,13 @@ } - public synchronized void setReadyReconnect(boolean ready) { + public synchronized void vncConnected(boolean ready) { if (ready && reconnecting) { + Socket vncSocket = viewer.getVNCSocket(); + NetworkInterface ni = getInterface(vncSocket); + if (ni!=null) { + System.out.println("VNCNetworkInterface :" + ni.getName()); + } sendDesktopSizeChange(reconnectingId); reconnecting = false; if (reconnectingId == 0) { @@ -373,7 +378,16 @@ } } - public synchronized void waitForReady() throws InterruptedException { + private NetworkInterface getInterface(Socket vncSocket) { + InetAddress address = vncSocket.getInetAddress(); + try { + return NetworkInterface.getByInetAddress(address); + } catch (SocketException e) { + return null; + } + } + + public synchronized void waitForVNCConnection() throws InterruptedException { if (reconnectingId!=0) { while (!readyReconnect) { wait(); @@ -408,7 +422,7 @@ if (context!=null) context.cleanUpSession(null); // cleanup zlib decoder for new VNCServer - if (isRoot()) + if (isTreeManager()) inflater = new Inflater(); } @@ -515,7 +529,7 @@ LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); ByteBuffer header = multicastqueue.allocate(16); ByteBuffer serial = multicastqueue.allocate(8); - if (!isRoot()) { + if (!isTreeManager()) { reader.readBytes(serial.array(),0,8); serial.limit(8); } @@ -640,7 +654,7 @@ // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary reconnecting = true; if (reconnectingId!=0) { - waitForReady(); + waitForVNCConnection(); } } @@ -654,7 +668,7 @@ treeManager.getList().getFirst().setPort(getAcceptPort()); } startTreeVncCommandListener(); - if(isRoot() && firstTime) { + if(isTreeManager() && firstTime) { getCast = new TreeRootFinderListener(v); Thread thread = new Thread(getCast, "tree-root-find-listener"); thread.start();
--- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Fri Jun 27 19:21:18 2014 +0900 @@ -318,4 +318,8 @@ } return null; } + + public Socket getSocket() { + return rfbConnectionWorker.getSocket(); + } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/CuiViewer.java Fri Jun 27 19:21:18 2014 +0900 @@ -270,4 +270,9 @@ public void setVisible(boolean b) { } + @Override + public Socket getVNCSocket() { + return connectionPresenter.getSocket(); + } + }
--- a/src/viewer_swing/java/com/glavsoft/viewer/RfbConnectionWorker.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/RfbConnectionWorker.java Fri Jun 27 19:21:18 2014 +0900 @@ -44,4 +44,6 @@ SwingViewerWindow getViewer(); + Socket getSocket(); + }
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Fri Jun 27 19:21:18 2014 +0900 @@ -353,7 +353,7 @@ */ @Override public void inhelitClients(ViewerInterface vs, String hostName) { - myRfb.setReadyReconnect(false); + myRfb.vncConnected(false); connectionParams.setConnectionParam(hostName, vncport); isApplet = true; this.setNoConnection(false); @@ -412,4 +412,9 @@ v.setVisible(b); } + @Override + public Socket getVNCSocket() { + return connectionPresenter.getSocket(); + } + }
--- a/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ViewerInterface.java Fri Jun 27 19:21:18 2014 +0900 @@ -35,4 +35,6 @@ public void setVisible(boolean b); + public Socket getVNCSocket(); + }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Fri Jun 27 18:50:49 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Fri Jun 27 19:21:18 2014 +0900 @@ -287,4 +287,9 @@ public SwingViewerWindow getViewer() { return viewerWindow; } + + @Override + public Socket getSocket() { + return workingSocket; + } }