Mercurial > hg > Applications > TreeVNC
annotate 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 |
rev | line source |
---|---|
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
1 package com.glavsoft.rfb.encoding.decoder; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
2 |
32 | 3 import jp.ac.u_ryukyu.treevnc.MyRfbProto; |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
4 |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
5 import com.glavsoft.drawing.Renderer; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
6 import com.glavsoft.exceptions.TransportException; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
7 import com.glavsoft.rfb.encoding.EncodingType; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
8 import com.glavsoft.transport.Reader; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
9 |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
10 public class ZRLEESender extends Decoder { |
66 | 11 |
29 | 12 private MyRfbProto rfb; |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
13 |
29 | 14 public ZRLEESender(MyRfbProto rfb) { |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
15 this.rfb = rfb; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
16 } |
66 | 17 |
18 public ZRLEESender() { | |
28 | 19 } |
66 | 20 |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
21 @Override |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
22 public void decode(Reader reader, Renderer renderer, |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
23 FramebufferUpdateRectangle rect) throws TransportException { |
66 | 24 int dataLen = getZrleLength(rect, reader); |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
25 reader.reset(); |
182 | 26 byte[] bytes = new byte[dataLen]; |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
103
diff
changeset
|
27 // TreeVNC handling |
182 | 28 rfb.readSendData(dataLen, reader, bytes); |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
103
diff
changeset
|
29 // reader is reseted read again |
66 | 30 |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
166
diff
changeset
|
31 if (rfb.hasViewer()) { |
166 | 32 reader.reset(); |
103 | 33 // decode data when it is a client |
182 | 34 if (!rfb.isRoot()) |
35 reader.readBytes(8); | |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
36 reader.readByte();// message |
66 | 37 reader.readByte();// padding |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
38 reader.readUInt16();// numberOfRectangle |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
39 rect.fill(reader);// fill |
182 | 40 ZRLEDecoder decoder = new ZRLEDecoder(); |
41 if (rfb.isRoot()) | |
42 decoder.decode1(reader, renderer, rect, bytes, dataLen); | |
43 else if (!rfb.getCuiVersion()) | |
66 | 44 decoder.decode(reader, renderer, rect); |
45 else { | |
46 reader.readBytes((int) reader.readUInt32()); | |
47 } | |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
48 } |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
49 } |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
50 |
66 | 51 private int getZrleLength(FramebufferUpdateRectangle rect, Reader reader) |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
52 throws TransportException { |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
53 int zrleLength = 0; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
54 if (rect.getEncodingType() == EncodingType.ZRLE |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
55 || rect.getEncodingType() == EncodingType.ZRLEE |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
56 || rect.getEncodingType() == EncodingType.ZLIB) { |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
57 zrleLength = reader.readInt32(); |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
58 } |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
59 return zrleLength + 20; |
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
60 } |
66 | 61 |
62 public void readCheckDelay(Reader reader) { | |
63 try { | |
64 reader.reset(); | |
65 rfb.readCheckDelay(reader); | |
66 } catch (TransportException e) { | |
67 e.printStackTrace(); | |
68 } | |
69 } | |
26
73b13bc335c2
add ZRLEESender.java, NullRenderer.java and NullRepaintController.java
one
parents:
diff
changeset
|
70 } |