Mercurial > hg > Applications > AliceVNC
view src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java @ 28:71dd46e2d706
send ServerInIt message
author | sugi |
---|---|
date | Sat, 08 Nov 2014 16:48:36 +0900 |
parents | 15398aebb0ef |
children | 556e27a53219 |
line wrap: on
line source
package jp.ac.u_ryukyu.alicevnc; import java.util.ArrayList; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.rfb.encoding.decoder.AliceVNCMessage; import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; import com.glavsoft.rfb.encoding.decoder.ZRLEDecoder; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class ReceiveUpdateRectangle extends CodeSegment{ private Receiver info = ids.create(CommandType.PEEK); private Receiver info1 = ids.create(CommandType.TAKE); // AliceVNC Message private Receiver info2 = ids.create(CommandType.TAKE); private Receiver info3 = ids.create(CommandType.PEEK); public ReceiveUpdateRectangle(){ info.setKey("Holder"); info1.setKey("aliceVNCMessage"); info2.setKey("pixelByteArray"); info3.setKey("_CLIST"); } @Override public void run() { // send other node @SuppressWarnings("unchecked") ArrayList<String> clist = info3.asClass(ArrayList.class); for (String node : clist){ if (!info1.from.equals(node)) { // not need send data comes from // Data Segment from other node is already serialized ods.put(node, "aliceVNCMessage", info1.getReceiveData()); //ods.setCompressFlag(true); ods.put(node, "pixelByteArray", info2.getReceiveData()); ods.setCompressFlag(false); } } try { RenderAndControllerHolder holder = info.asClass(RenderAndControllerHolder.class); AliceVNCMessage message = info1.asClass(AliceVNCMessage.class); if (message.getEncodingType() == EncodingType.ZRLEE){ ZRLEDecoder decoder = new ZRLEDecoder(); FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle( message.x, message.y, message.width, message.height); rect.encodingType = message.getEncodingType(); byte[] buf = info2.asClass(byte[].class); // this method name is wrong. decoder.decode(holder.getRenderer(), rect, buf, 0); holder.getRepaintController().repaintBitmap(rect); } else if (message.getEncodingType() == EncodingType.DESKTOP_SIZE) { holder.setRenderer( holder.getRepaintController().createRenderer(null, message.width, message.height, message.getPixelFormat()) ); } else if (message.getEncodingType() == EncodingType.RICH_CURSOR) { byte[] buf = info2.asClass(byte[].class); RichCursorDecoder.getInstance().decode(holder.getRenderer(), message, buf); holder.getRepaintController().repaintCursor(); } this.recycle(); } catch (TransportException e) { e.printStackTrace(); } } }