Mercurial > hg > Applications > AliceVNC
annotate src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java @ 40:47d6f7a76b86
for measurement
author | sugi |
---|---|
date | Mon, 08 Dec 2014 22:05:56 +0900 |
parents | 1fa4b7b8d19f |
children | 1cb529b46876 |
rev | line source |
---|---|
2 | 1 package jp.ac.u_ryukyu.alicevnc; |
2 | |
5
c05d3b89b446
Send DecodeInfo to Children Nodes. but occur ArrayIndexOutOfBoundsException.
YU
parents:
4
diff
changeset
|
3 import java.util.ArrayList; |
c05d3b89b446
Send DecodeInfo to Children Nodes. but occur ArrayIndexOutOfBoundsException.
YU
parents:
4
diff
changeset
|
4 |
32 | 5 import jp.ac.u_ryukyu.ie.cr.DecodeInfomation; |
6 | |
2 | 7 import com.glavsoft.exceptions.TransportException; |
4 | 8 import com.glavsoft.rfb.encoding.EncodingType; |
2 | 9 import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; |
12 | 10 import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; |
2 | 11 import com.glavsoft.rfb.encoding.decoder.ZRLEDecoder; |
12 | |
13 import alice.codesegment.CodeSegment; | |
14 import alice.datasegment.CommandType; | |
40 | 15 import alice.datasegment.ReceiveData; |
2 | 16 import alice.datasegment.Receiver; |
17 | |
18 public class ReceiveUpdateRectangle extends CodeSegment{ | |
19 | |
20 private Receiver info = ids.create(CommandType.PEEK); | |
17 | 21 private Receiver info1 = ids.create(CommandType.TAKE); // AliceVNC Message |
22 private Receiver info2 = ids.create(CommandType.TAKE); | |
23 private Receiver info3 = ids.create(CommandType.PEEK); | |
5
c05d3b89b446
Send DecodeInfo to Children Nodes. but occur ArrayIndexOutOfBoundsException.
YU
parents:
4
diff
changeset
|
24 |
2 | 25 public ReceiveUpdateRectangle(){ |
31 | 26 info.setKey("holder"); |
32 | 27 info1.setKey("updateRectangle"); |
28 info2.setKey("pixelData"); | |
17 | 29 info3.setKey("_CLIST"); |
2 | 30 } |
5
c05d3b89b446
Send DecodeInfo to Children Nodes. but occur ArrayIndexOutOfBoundsException.
YU
parents:
4
diff
changeset
|
31 |
10 | 32 @Override |
2 | 33 public void run() { |
40 | 34 // for measurement; |
35 long time = System.currentTimeMillis(); | |
36 MeasurementData md = null; | |
37 if (info2.getReceiveData().setTime) { | |
38 ReceiveData r = info2.getReceiveData(); | |
39 md = new MeasurementData(); | |
40 md.depth = r.depth; | |
41 md.time = time - r.time; | |
42 md.size = ((byte[])info2.getObj()).length; | |
43 } | |
17 | 44 // send other node |
45 @SuppressWarnings("unchecked") | |
46 ArrayList<String> clist = info3.asClass(ArrayList.class); | |
47 for (String node : clist){ | |
31 | 48 if (!info1.from.equals(node)) { |
17 | 49 // not need send data comes from |
31 | 50 // Data Segment from other node is already serialized |
35 | 51 ods.put(node, "updateRectangle", info1.getReceiveData()); //TODO need timeout counter |
20 | 52 //ods.setCompressFlag(true); |
40 | 53 |
54 // for measurement | |
55 ReceiveData r = info2.getReceiveData(); | |
56 if (!r.setTime) { | |
57 r.setTime = true; | |
58 r.time = System.currentTimeMillis(); | |
59 } | |
32 | 60 ods.put(node, "pixelData", info2.getReceiveData()); |
19 | 61 ods.setCompressFlag(false); |
17 | 62 } |
40 | 63 } |
31 | 64 |
65 | |
2 | 66 try { |
10 | 67 RenderAndControllerHolder holder = info.asClass(RenderAndControllerHolder.class); |
32 | 68 DecodeInfomation message = info1.asClass(DecodeInfomation.class); |
10 | 69 |
35 | 70 if (message.getEncodingType() == EncodingType.ZRLEE){ //TODO |
10 | 71 ZRLEDecoder decoder = new ZRLEDecoder(); |
72 FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle( | |
73 message.x, message.y, message.width, message.height); | |
12 | 74 rect.encodingType = message.getEncodingType(); |
17 | 75 byte[] buf = info2.asClass(byte[].class); |
31 | 76 |
17 | 77 // this method name is wrong. |
19 | 78 decoder.decode(holder.getRenderer(), rect, buf, 0); |
10 | 79 holder.getRepaintController().repaintBitmap(rect); |
80 | |
31 | 81 } else if (message.getEncodingType() == EncodingType.DESKTOP_SIZE) { |
10 | 82 holder.setRenderer( |
31 | 83 holder.getRepaintController().createRenderer(null, message.width, |
11 | 84 message.height, message.getPixelFormat()) |
10 | 85 ); |
33 | 86 boolean visible = true; |
87 if ("local".equals(info2.from)) { | |
88 visible = false; | |
89 } | |
90 holder.getViewerWindow().setVisible(visible); | |
12 | 91 } else if (message.getEncodingType() == EncodingType.RICH_CURSOR) { |
17 | 92 byte[] buf = info2.asClass(byte[].class); |
93 RichCursorDecoder.getInstance().decode(holder.getRenderer(), message, buf); | |
12 | 94 holder.getRepaintController().repaintCursor(); |
31 | 95 |
12 | 96 } |
40 | 97 // for measurement |
98 if (md !=null) | |
99 ods.put("parent", "measurement", md); | |
100 | |
35 | 101 this.recycle(); //TODO |
10 | 102 |
2 | 103 } catch (TransportException e) { |
104 e.printStackTrace(); | |
105 } | |
106 } | |
107 | |
108 } |