Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java @ 182:b3426724667b
fix read send data.
author | oc |
---|---|
date | Mon, 23 Jun 2014 19:30:51 +0900 |
parents | 34b7558aeffa |
children | 6f452c497e0e |
line wrap: on
line source
package com.glavsoft.rfb.encoding.decoder; import jp.ac.u_ryukyu.treevnc.MyRfbProto; import com.glavsoft.drawing.Renderer; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.transport.Reader; public class ZRLEESender extends Decoder { private MyRfbProto rfb; public ZRLEESender(MyRfbProto rfb) { this.rfb = rfb; } public ZRLEESender() { } @Override public void decode(Reader reader, Renderer renderer, FramebufferUpdateRectangle rect) throws TransportException { int dataLen = getZrleLength(rect, reader); reader.reset(); byte[] bytes = new byte[dataLen]; // TreeVNC handling rfb.readSendData(dataLen, reader, bytes); // reader is reseted read again if (rfb.hasViewer()) { reader.reset(); // decode data when it is a client if (!rfb.isRoot()) reader.readBytes(8); reader.readByte();// message reader.readByte();// padding reader.readUInt16();// numberOfRectangle rect.fill(reader);// fill ZRLEDecoder decoder = new ZRLEDecoder(); if (rfb.isRoot()) decoder.decode1(reader, renderer, rect, bytes, dataLen); else if (!rfb.getCuiVersion()) decoder.decode(reader, renderer, rect); else { reader.readBytes((int) reader.readUInt32()); } } } private int getZrleLength(FramebufferUpdateRectangle rect, Reader reader) throws TransportException { int zrleLength = 0; if (rect.getEncodingType() == EncodingType.ZRLE || rect.getEncodingType() == EncodingType.ZRLEE || rect.getEncodingType() == EncodingType.ZLIB) { zrleLength = reader.readInt32(); } return zrleLength + 20; } public void readCheckDelay(Reader reader) { try { reader.reset(); rfb.readCheckDelay(reader); } catch (TransportException e) { e.printStackTrace(); } } }