Mercurial > hg > Applications > TreeVNC
annotate src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java @ 256:dfec8bc1eb8e
fix --retina option
author | oc |
---|---|
date | Tue, 18 Nov 2014 14:10:53 +0900 (2014-11-18) |
parents | a931be447973 |
children | 11b59b223222 |
rev | line source |
---|---|
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC. |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 // All rights reserved. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is part of the TightVNC software. Please visit our Web site: |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 // http://www.tightvnc.com/ |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 // This program is free software; you can redistribute it and/or modify |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // it under the terms of the GNU General Public License as published by |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // the Free Software Foundation; either version 2 of the License, or |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 // (at your option) any later version. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 // This program is distributed in the hope that it will be useful, |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 // GNU General Public License for more details. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 // You should have received a copy of the GNU General Public License along |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 // with this program; if not, write to the Free Software Foundation, Inc., |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 package com.glavsoft.rfb.protocol; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 import com.glavsoft.drawing.Renderer; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 import com.glavsoft.exceptions.CommonException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 import com.glavsoft.exceptions.ProtocolException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 import com.glavsoft.exceptions.TransportException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 import com.glavsoft.rfb.ClipboardController; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 import com.glavsoft.rfb.IRepaintController; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 import com.glavsoft.rfb.client.FramebufferUpdateRequestMessage; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 import com.glavsoft.rfb.client.SetPixelFormatMessage; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 import com.glavsoft.rfb.encoding.EncodingType; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 import com.glavsoft.rfb.encoding.PixelFormat; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 import com.glavsoft.rfb.encoding.decoder.Decoder; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 import com.glavsoft.rfb.encoding.decoder.DecodersContainer; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; |
66 | 41 import com.glavsoft.rfb.encoding.decoder.ZRLEESender; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 import com.glavsoft.transport.Reader; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 import java.io.PrintWriter; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 import java.io.StringWriter; |
167 | 46 import java.io.UnsupportedEncodingException; |
255 | 47 import java.util.Timer; |
48 import java.util.TimerTask; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 import java.util.logging.Logger; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 |
230 | 51 import jp.ac.u_ryukyu.treevnc.CheckDelayReply; |
239 | 52 import jp.ac.u_ryukyu.treevnc.SendCheckDelay; |
207 | 53 import jp.ac.u_ryukyu.treevnc.TreeRFBProto; |
206 | 54 import jp.ac.u_ryukyu.treevnc.TreeVncProtocol; |
231 | 55 |
35 | 56 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 public class ReceiverTask implements Runnable { |
224 | 58 private static final byte FRAMEBUFFER_UPDATE = 0; |
59 private static final byte SET_COLOR_MAP_ENTRIES = 1; | |
60 private static final byte BELL = 2; | |
61 private static final byte SERVER_CUT_TEXT = 3; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 |
224 | 64 private static Logger logger = Logger.getLogger("com.glavsoft.rfb.protocol.ReceiverTask"); |
65 private final Reader reader; | |
66 private volatile boolean isRunning = false; | |
67 private Renderer renderer; | |
68 private final IRepaintController repaintController; | |
69 private final ClipboardController clipboardController; | |
70 protected final DecodersContainer decoders; | |
71 protected FramebufferUpdateRequestMessage fullscreenFbUpdateIncrementalRequest; | |
72 protected final ProtocolContext context; | |
73 protected PixelFormat pixelFormat; | |
74 protected boolean needSendPixelFormat; | |
75 private TreeRFBProto rfb; | |
76 private long checkCounter = 0; | |
239 | 77 private boolean firstTime = true; |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
78 public int numberOfRectangles = 0; |
255 | 79 private Timer timer = null; |
224 | 80 |
255 | 81 |
224 | 82 public ReceiverTask(Reader reader, |
35 | 83 IRepaintController repaintController, ClipboardController clipboardController, |
84 DecodersContainer decoders, ProtocolContext context, | |
207 | 85 TreeRFBProto _rfb) { |
224 | 86 rfb = _rfb; |
87 this.reader = reader; | |
88 this.repaintController = repaintController; | |
89 this.clipboardController = clipboardController; | |
90 this.context = context; | |
91 this.decoders = decoders; | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
176
diff
changeset
|
92 |
224 | 93 Decoder decoder = new ZRLEESender(rfb); |
94 decoders.setDecoderByType(EncodingType.ZLIB, decoder); | |
95 decoders.setDecoderByType(EncodingType.ZRLE, decoder); | |
96 decoders.setDecoderByType(EncodingType.ZRLEE, decoder); | |
97 | |
98 if(!rfb.getCuiVersion()) | |
99 renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(),context.getPixelFormat()); | |
255 | 100 fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); |
224 | 101 if(rfb.isTreeManager()) { |
102 fullscreenFbUpdateIncrementalRequest.sendFullScreenRequest(); | |
103 connectionFinished(); | |
104 } | |
105 } | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
176
diff
changeset
|
106 |
224 | 107 @Override |
108 public void run() { | |
109 isRunning = true; | |
110 while (isRunning) { | |
111 try { | |
112 if(! rfb.isTreeManager()) { | |
113 // client has 8byte packet sequence number | |
242 | 114 // add serial number flag (4byte) |
115 reader.mark(20+8+4); | |
116 getLost(reader); //check seq consistency | |
224 | 117 } else { |
118 reader.mark(20); | |
119 } | |
120 byte messageId = reader.readByte(); | |
121 switch (messageId) { | |
122 case FRAMEBUFFER_UPDATE: | |
239 | 123 // logger.fine("Server message: FramebufferUpdate (0)"); |
224 | 124 framebufferUpdateMessage(); |
125 break; | |
126 case SET_COLOR_MAP_ENTRIES: | |
127 logger.severe("Server message SetColorMapEntries is not implemented. Skip."); | |
128 setColorMapEntries(); | |
129 break; | |
130 case BELL: | |
131 logger.fine("Server message: Bell"); | |
239 | 132 // System.out.print("\0007"); |
133 // System.out.flush(); | |
224 | 134 break; |
135 case SERVER_CUT_TEXT: | |
136 logger.fine("Server message: CutText (3)"); | |
137 serverCutText(); | |
138 break; | |
139 default: | |
140 logger.severe("Unsupported server message. Id = " + messageId); | |
141 } | |
142 } catch (TransportException e) { | |
133 | 143 logger.severe("Close session: " + e.getMessage()); |
224 | 144 if(!rfb.isTreeManager() && !(rfb.getTerminationType())) { |
145 System.out.println("task stop"); | |
146 TreeVncProtocol echo = new TreeVncProtocol(rfb.getConnectionParam().getHostName(), rfb.getConnectionParam().getPort()); | |
147 int counter = 3; | |
148 while(counter-- > 0) { | |
149 try { | |
150 if (rfb.isLeader()) { | |
151 echo.lostParent(rfb.getMyAddress(),rfb.getAcceptPort()); | |
152 } | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
153 break; |
133 | 154 } catch (Exception e1) { |
155 logger.severe("Cannot send lostHost: " + e1.getMessage()); | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
156 sleep(3000); |
133 | 157 } |
224 | 158 } |
159 } | |
160 stopTask(); | |
161 } catch (ProtocolException e) { | |
162 logger.severe(e.getMessage()); | |
163 if (isRunning) { | |
164 context.cleanUpSession(e.getMessage() + "\nConnection closed."); | |
165 } | |
166 stopTask(); | |
167 } catch (CommonException e) { | |
168 logger.severe(e.getMessage()); | |
169 if (isRunning) { | |
170 context.cleanUpSession("Connection closed.."); | |
171 } | |
172 stopTask(); | |
173 } catch (Throwable te) { | |
174 StringWriter sw = new StringWriter(); | |
175 PrintWriter pw = new PrintWriter(sw); | |
176 te.printStackTrace(pw); | |
177 logger.severe(te.getMessage()); | |
178 if (isRunning) { | |
179 context.cleanUpSession(te.getMessage() + "\n" + sw.toString()); | |
180 } | |
181 stopTask(); | |
182 } | |
183 } | |
184 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 |
224 | 186 private void sleep(int i) { |
187 try { | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
188 Thread.sleep(i); |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
189 } catch (InterruptedException e) { |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
190 // nothing. |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
191 } |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
192 } |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
193 |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
194 |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
195 private void setColorMapEntries() throws TransportException { |
224 | 196 reader.readByte(); // padding |
197 reader.readUInt16(); // first color index | |
198 int length = reader.readUInt16(); | |
199 while (length-- > 0) { | |
200 reader.readUInt16(); // R | |
201 reader.readUInt16(); // G | |
202 reader.readUInt16(); // B | |
203 } | |
204 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 |
224 | 206 private void serverCutText() throws TransportException { |
207 reader.readByte(); // padding | |
208 reader.readInt16(); // padding | |
209 int length = reader.readInt32() & Integer.MAX_VALUE; | |
210 clipboardController.updateSystemClipboard(reader.readBytes(length)); | |
211 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 |
224 | 213 public void framebufferUpdateMessage() throws CommonException, UnsupportedEncodingException { |
214 reader.readByte(); // padding | |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
215 |
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
216 this.numberOfRectangles = reader.readUInt16(); |
250 | 217 |
218 if(numberOfRectangles != 1) | |
219 System.out.println("numberofrectangle : " + numberOfRectangles); | |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
220 |
255 | 221 if(rfb.isTreeManager() && firstTime) { |
222 if(rfb.checkDelay) { | |
223 SendCheckDelay sendCheckDelay = new SendCheckDelay(rfb); | |
224 Thread sendCheckDelayThread = new Thread(sendCheckDelay, "send-check-delay"); | |
225 sendCheckDelayThread.start(); | |
226 this.firstTime = false; | |
227 } | |
228 | |
256 | 229 if(rfb.fixRetinaDisplay) { |
230 timer = new Timer(true); | |
231 timer.schedule(new TimerTask() { | |
232 @Override | |
233 public void run() { | |
234 context.setFbWidth(1280); | |
235 context.setFbHeight(800); | |
236 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true)); | |
237 } | |
238 }, 0, 100); | |
239 } | |
239 | 240 } |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
241 |
250 | 242 while (numberOfRectangles-- > 0) { |
224 | 243 FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); |
244 rect.fill(reader); | |
250 | 245 |
252 | 246 long time = System.currentTimeMillis(); |
256 | 247 if(rfb.isTreeManager() && rfb.checkDelay) |
252 | 248 System.out.println(time + " : size : " + rect.width * rect.height); |
250 | 249 |
224 | 250 Decoder decoder = decoders.getDecoderByType(rect.getEncodingType()); |
250 | 251 logger.finest(rect.toString() + (0 == numberOfRectangles ? "\n---" : "")); |
224 | 252 if (decoder != null) { |
253 decoder.decode(reader, renderer, rect); // TreeVNC processing here | |
254 if(!(rfb.getCuiVersion())) | |
255 repaintController.repaintBitmap(rect); | |
256 } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) { | |
257 RichCursorDecoder.getInstance().decode(reader, renderer, rect); | |
258 if(repaintController!=null) | |
259 repaintController.repaintCursor(); | |
260 } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { | |
261 renderer.decodeCursorPosition(rect); | |
262 repaintController.repaintCursor(); | |
263 } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE || rect.getEncodingType() == EncodingType.INIT_DATA ) { | |
255 | 264 fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false); |
106
01c0fd20c0b4
share screen enable cui flag.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
103
diff
changeset
|
265 rfb.setCuiVersion(false); |
171 | 266 boolean visible = true; |
164 | 267 if (rect.getEncodingType() == EncodingType.INIT_DATA) { |
224 | 268 int length = reader.readInt32(); |
269 byte[] initData = new byte[length]; | |
270 reader.read(initData); | |
271 String name = new String(initData, 24, length - 24, "UTF-8"); | |
272 rfb.getContext().setRemoteDesktopName(name); | |
273 rfb.getContext().setInitData(initData); | |
274 repaintController.updateRemoteDesktopName(rfb.getContext()); | |
275 reader.reset(); | |
276 rfb.readSendData(length + 20, reader, null ); // size of UpdateRectangleMessage with initData. | |
277 short id = (short) rect.x; | |
278 visible = (id != rfb.getId()); | |
164 | 279 } |
171 | 280 synchronized (renderer.getLock()) { |
224 | 281 if(!(rfb.getCuiVersion())) |
255 | 282 renderer = repaintController.createRenderer(reader, rect.width, rect.height, context.getPixelFormat()); |
171 | 283 } |
284 if (rect.getEncodingType() == EncodingType.INIT_DATA) { | |
224 | 285 repaintController.setVisible(visible); |
171 | 286 } |
255 | 287 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); |
224 | 288 // repaintController.repaintCursor(); |
227
2cb2279ca95c
send checkdelay time.
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
226
diff
changeset
|
289 } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { |
242 | 290 int checkDelaySize = 24; |
229
5eb8aa65f387
fix checkdelay number-of-rectangle, and send checkdelay to lower node.
oc
parents:
228
diff
changeset
|
291 reader.reset(); |
237 | 292 rfb.readSendData(checkDelaySize, reader, null); |
234 | 293 int port = rfb.acceptPort; |
294 String address = rfb.getMyAddress(); | |
295 sendCheckDelayReply(rect.time, port, address); | |
224 | 296 } else |
297 throw new CommonException("Unprocessed encoding: " + rect.toString()); | |
298 } | |
239 | 299 |
300 if (!rfb.isTreeManager()) { | |
301 return; | |
302 } | |
224 | 303 synchronized (this) { |
304 if (needSendPixelFormat) { | |
305 needSendPixelFormat = false; | |
306 context.setPixelFormat(pixelFormat); | |
307 context.sendMessage(new SetPixelFormatMessage(pixelFormat)); | |
308 logger.fine("sent: "+pixelFormat); | |
309 context.sendRefreshMessage(); | |
310 logger.fine("sent: nonincremental fb update"); | |
311 } else { | |
255 | 312 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), false)); |
224 | 313 } |
314 } | |
315 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316 |
234 | 317 private void sendCheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { |
318 context.sendMessage(new CheckDelayReply(time, port, address)); | |
230 | 319 } |
320 | |
224 | 321 public synchronized void queueUpdatePixelFormat(PixelFormat pf) { |
322 pixelFormat = pf; | |
323 needSendPixelFormat = true; | |
324 // context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, 1, 1, false)); | |
325 } | |
326 | |
327 public void stopTask() { | |
328 isRunning = false; | |
329 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
330 |
224 | 331 private void connectionFinished() { |
332 rfb.vncConnected(true); | |
333 } | |
334 | |
335 private void getLost(Reader reader) throws Exception { | |
242 | 336 int addSerialNumFlag = reader.readInt32(); |
224 | 337 long num = reader.readInt64(); |
243 | 338 if (addSerialNumFlag == 1) { |
339 rfb.setAddSerialNum(true); | |
340 if(num != ++checkCounter) { | |
341 System.out.println("LostData" + (num - checkCounter)); | |
342 checkCounter = num; | |
343 } | |
224 | 344 } |
345 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
346 } |