Mercurial > hg > Applications > TreeVNC
changeset 567:ac8fd355b8bb
fix -p mode
don't use waitput
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 05 Feb 2020 10:17:00 +0900 |
parents | e93a8058344d |
children | 44920845d4e1 |
files | src/main/java/com/glavsoft/rfb/client/FramebufferUpdateRequestMessage.java src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java |
diffstat | 5 files changed, 29 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/client/FramebufferUpdateRequestMessage.java Mon Feb 03 19:56:08 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/client/FramebufferUpdateRequestMessage.java Wed Feb 05 10:17:00 2020 +0900 @@ -40,7 +40,12 @@ private final int x; private boolean sendFullScreenFlag; - + int sendFullScreenTimer = 50 * 1000; // in msec + + public void setSendFullScreenTimer(int sendFullScreenTimer) { + this.sendFullScreenTimer = sendFullScreenTimer; + } + public FramebufferUpdateRequestMessage(int x, int y, int width, int height, boolean fullScreen) { this.x = x; @@ -84,7 +89,6 @@ public void sendFullScreenRequest(ProtocolContext context) { if (! context.isRunning()) return; context.sendRefreshMessage(); - int sendFullScreenTimer = 50 * 1000; TimerTask tt = new TimerTask() { @Override public void run() {
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Mon Feb 03 19:56:08 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Wed Feb 05 10:17:00 2020 +0900 @@ -57,11 +57,10 @@ } } if (rfb.multicastBlocking) { - // do something ZRLEDecoder decoder = new ZRLEDecoder(); decoder.multicastDecode(reader, renderer, rect, rfb); } else { - byte[] bytes = new byte[dataLen]; + byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; rfb.readSendData(dataLen, reader, bytes, rect); } }
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Feb 03 19:56:08 2020 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Wed Feb 05 10:17:00 2020 +0900 @@ -124,7 +124,6 @@ return; } byte messageId = getMessageId(reader); - switch (messageId) { case FRAMEBUFFER_UPDATE: // logger.fine("Server message: FramebufferUpdate (0)"); @@ -205,7 +204,6 @@ } else { reader.mark(20+4); } - rfb.messageDump(reader, "get receive massage: "); return reader.readByte(); } @@ -372,7 +370,6 @@ } catch (Exception e) { System.out.println("FrameBufferUpdate: "+e); } - sendFrameBufferUpdateRequest(); } @@ -390,8 +387,8 @@ Decoder decoder = decoders.getDecoderByType(rect.getEncodingType()); decoder.decode(in,new NullRenderer(context.getPixelFormat().bitsPerPixel/8),rect); } - } catch (Exception e) { - ; + } catch (Exception e) { + e.printStackTrace(); } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Mon Feb 03 19:56:08 2020 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java Wed Feb 05 10:17:00 2020 +0900 @@ -350,7 +350,7 @@ while (inputIndex < bufs.size()) { ByteBuffer b = bufs.get(inputIndex++); os.write(b.array(), b.position(), b.limit()); - messageDump(new Reader(new ByteArrayInputStream(b.array())), "write to client: "); + messageDump(b.array(),b.limit()-b.position(),24, "write to client: "); } os.flush(); multicastqueue.heapAvailable(); @@ -615,10 +615,8 @@ int limit = bytes.length; while (inputIndex < inputs.size()) { ByteBuffer input = inputs.get(inputIndex++); - inflater.setInput(input.array(), input.position(), input.limit()); - // if (inputIndex==inputs.size()) if inflater/deflater has symmetry, - // we need this - // inflater.end(); but this won't work + //inflater.setInput(input.array(), input.position(), input.limit()); + inflater.setInput(input); do { int len0; len0 = inflater.inflate(bytes, position, limit - position); @@ -626,7 +624,7 @@ position += len0; if (position > limit) throw new DataFormatException(); } - } while (!inflater.needsInput()); + } while (input.hasRemaining() && !inflater.needsInput()); } return position; } @@ -659,7 +657,6 @@ if (encoding == EncodingType.ZRLE.getId() || encoding == EncodingType.ZLIB.getId()) { - // recompress into ZREE // uncompressed result is remain in bytes ByteBuffer len = multicastqueue.allocate(4); @@ -670,11 +667,9 @@ inputData.limit(dataLen - 20); LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>(); inputs.add(inputData); - header.putInt(12, EncodingType.ZRLEE.getId()); // means - // recompress - // every time - // using new Deflecter every time is incompatible with the - // protocol, clients have to be modified. + header.putInt(12, EncodingType.ZRLEE.getId()); + // ZRLEE : using new Deflecter every time + // ZRLE : reuse dict everytime (compatible mode) Deflater nDeflater = deflater; // new Deflater(); LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); try { @@ -694,8 +689,8 @@ if (addSerialNum) { addSerialNumber(bufs); } - multicastqueue.waitput(bufs); - } catch (IOException | InterruptedException e) { + multicastqueue.put(bufs); + } catch (IOException e ) { throw new TransportException(e); } catch (DataFormatException e) { throw new TransportException(e); @@ -955,16 +950,10 @@ } } - public void messageDump(Reader reader, String msg) { + public void messageDump(byte[] data,int limit, int disp, String msg) { System.out.print(msg); - try { - reader.mark(24); - for (int i = 0; i < 24; i++) { // 20 + 4 - System.out.print(String.format("%02x ", reader.readByte())); - } - reader.reset(); - } catch (TransportException e) { - + for (int i = 0; i < disp && i < limit; i++) { // 20 + 4 + System.out.print(String.format("%02x ", data[i])); } System.out.println(); }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Mon Feb 03 19:56:08 2020 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Wed Feb 05 10:17:00 2020 +0900 @@ -66,6 +66,7 @@ protected ProtocolSettings rfbSettings; protected UiSettings uiSettings; private TreeRFBProto myRfb; + private int useSocketTimeout = 1000; // msec @Override public Void doInBackground() throws Exception { @@ -184,11 +185,13 @@ rc = new NullRepaintController(); } workingProtocol.startNormalHandling(this,rc, clipboardController, myRfb); -// try { -// workingSocket.setSoTimeout(1000); -// } catch (SocketException e) { -// e.printStackTrace(); -// } + if (useSocketTimeout > 0) { + try { + workingSocket.setSoTimeout(useSocketTimeout); + } catch (SocketException e) { + e.printStackTrace(); + } + } presenter.showMessage("Started"); if(!myRfb.getCuiVersion())