Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/protocol/TreeTask.java @ 16:e654b2e4de64
add TreeTask.java
author | one |
---|---|
date | Mon, 27 Aug 2012 06:31:14 +0900 |
parents | |
children | ea83f4be0cc9 |
line wrap: on
line source
package com.glavsoft.rfb.protocol; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.nio.ByteBuffer; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; import jp.ac.u_ryukyu.treevnc.MulticastQueue; import jp.ac.u_ryukyu.treevnc.server.*; import com.glavsoft.exceptions.CommonException; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.ClipboardController; import com.glavsoft.rfb.IRepaintController; import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage; import com.glavsoft.rfb.client.SetPixelFormatMessage; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.rfb.encoding.decoder.Decoder; import com.glavsoft.rfb.encoding.decoder.DecodersContainer; import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; import com.glavsoft.transport.Reader; public class TreeTask extends ReceiverTask { private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); private int clients = 0; private RequestScreenThread rThread; final static String versionMsg_3_855 = "RFB 003.855\n"; private Reader reader; public TreeTask(Reader reader, IRepaintController repaintController, ClipboardController clipboardController, DecodersContainer decoders, ProtocolContext context,boolean flag) { super(reader, repaintController, clipboardController, decoders, context,true); } @Override public void framebufferUpdateMessage() throws CommonException{ reader.readByte(); // padding int numberOfRectangles = reader.readUInt16(); while (numberOfRectangles-- > 0) { FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); rect.fill(reader); Decoder decoder = decoders.getDecoderByType(rect.getEncodingType()); logger.finest(rect.toString() + (0 == numberOfRectangles ? "\n---" : "")); if (decoder != null) { decoder.decode(reader, renderer, rect); repaintController.repaintBitmap(rect); } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) { RichCursorDecoder.getInstance().decode(reader, renderer, rect); repaintController.repaintCursor(); } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { renderer.decodeCursorPosition(rect); repaintController.repaintCursor(); } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE) { fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, true); synchronized (renderer) { renderer = repaintController.createRenderer(reader, rect.width, rect.height, context.getPixelFormat()); } // repaintController.repaintCursor(); } else throw new CommonException("Unprocessed encoding: " + rect.toString()); } } }