Mercurial > hg > Applications > AliceVNC
annotate src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java @ 47:9354e8a1d03b
working AliceVNC
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 19 Oct 2015 23:48:18 +0900 |
parents | fecac17d662a |
children | 57ca704f86a3 |
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(){ |
47 | 26 info.setKey("holder", this); |
27 info1.setKey("updateRectangle", this); | |
28 info2.setKey("pixelData", this); | |
29 info3.setKey("_CLIST", this); | |
2 | 30 } |
5
c05d3b89b446
Send DecodeInfo to Children Nodes. but occur ArrayIndexOutOfBoundsException.
YU
parents:
4
diff
changeset
|
31 |
41 | 32 @SuppressWarnings("unchecked") |
10 | 33 @Override |
2 | 34 public void run() { |
41 | 35 |
17 | 36 // send other node |
37 ArrayList<String> clist = info3.asClass(ArrayList.class); | |
43 | 38 // for measurement |
39 if (info2.getReceiveData().setTime) { | |
40 ods.put("parnet", "measurement", info2.getReceiveData()); | |
41 } | |
17 | 42 for (String node : clist){ |
31 | 43 if (!info1.from.equals(node)) { |
17 | 44 // not need send data comes from |
31 | 45 // Data Segment from other node is already serialized |
35 | 46 ods.put(node, "updateRectangle", info1.getReceiveData()); //TODO need timeout counter |
20 | 47 //ods.setCompressFlag(true); |
40 | 48 |
49 // for measurement | |
50 ReceiveData r = info2.getReceiveData(); | |
51 if (!r.setTime) { | |
44 | 52 r.depth = 0; |
40 | 53 r.setTime = true; |
54 r.time = System.currentTimeMillis(); | |
55 } | |
32 | 56 ods.put(node, "pixelData", info2.getReceiveData()); |
17 | 57 } |
40 | 58 } |
31 | 59 |
2 | 60 try { |
10 | 61 RenderAndControllerHolder holder = info.asClass(RenderAndControllerHolder.class); |
32 | 62 DecodeInfomation message = info1.asClass(DecodeInfomation.class); |
10 | 63 |
35 | 64 if (message.getEncodingType() == EncodingType.ZRLEE){ //TODO |
10 | 65 ZRLEDecoder decoder = new ZRLEDecoder(); |
66 FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle( | |
67 message.x, message.y, message.width, message.height); | |
12 | 68 rect.encodingType = message.getEncodingType(); |
17 | 69 byte[] buf = info2.asClass(byte[].class); |
31 | 70 |
17 | 71 // this method name is wrong. |
19 | 72 decoder.decode(holder.getRenderer(), rect, buf, 0); |
10 | 73 holder.getRepaintController().repaintBitmap(rect); |
74 | |
31 | 75 } else if (message.getEncodingType() == EncodingType.DESKTOP_SIZE) { |
10 | 76 holder.setRenderer( |
31 | 77 holder.getRepaintController().createRenderer(null, message.width, |
11 | 78 message.height, message.getPixelFormat()) |
10 | 79 ); |
33 | 80 boolean visible = true; |
81 if ("local".equals(info2.from)) { | |
82 visible = false; | |
83 } | |
84 holder.getViewerWindow().setVisible(visible); | |
12 | 85 } else if (message.getEncodingType() == EncodingType.RICH_CURSOR) { |
17 | 86 byte[] buf = info2.asClass(byte[].class); |
87 RichCursorDecoder.getInstance().decode(holder.getRenderer(), message, buf); | |
12 | 88 holder.getRepaintController().repaintCursor(); |
31 | 89 |
12 | 90 } |
40 | 91 |
35 | 92 this.recycle(); //TODO |
10 | 93 |
2 | 94 } catch (TransportException e) { |
95 e.printStackTrace(); | |
96 } | |
97 } | |
98 | |
99 } |