Mercurial > hg > Applications > TreeVNC
annotate src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java @ 358:59b1ef1b0a89
fix ilter single display (HiDPI)
author | oc |
---|---|
date | Tue, 03 Mar 2015 17:58:41 +0900 |
parents | eba44a31e868 |
children | 62a6c779fd7f |
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; |
278 | 37 import com.glavsoft.rfb.encoding.decoder.*; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 import com.glavsoft.transport.Reader; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 import java.io.PrintWriter; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 import java.io.StringWriter; |
167 | 42 import java.io.UnsupportedEncodingException; |
255 | 43 import java.util.Timer; |
44 import java.util.TimerTask; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 import java.util.logging.Logger; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 |
332
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
47 import com.glavsoft.viewer.ViewerInterface; |
279 | 48 import jp.ac.u_ryukyu.treevnc.*; |
231 | 49 |
35 | 50 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 public class ReceiverTask implements Runnable { |
224 | 52 private static final byte FRAMEBUFFER_UPDATE = 0; |
53 private static final byte SET_COLOR_MAP_ENTRIES = 1; | |
54 private static final byte BELL = 2; | |
55 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
|
56 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 |
224 | 58 private static Logger logger = Logger.getLogger("com.glavsoft.rfb.protocol.ReceiverTask"); |
336 | 59 private Reader reader; |
224 | 60 private volatile boolean isRunning = false; |
61 private Renderer renderer; | |
62 private final IRepaintController repaintController; | |
63 private final ClipboardController clipboardController; | |
64 protected final DecodersContainer decoders; | |
65 protected FramebufferUpdateRequestMessage fullscreenFbUpdateIncrementalRequest; | |
66 protected final ProtocolContext context; | |
67 protected PixelFormat pixelFormat; | |
68 protected boolean needSendPixelFormat; | |
69 private TreeRFBProto rfb; | |
70 private long checkCounter = 0; | |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
71 public int numberOfRectangles = 0; |
255 | 72 private Timer timer = null; |
358 | 73 private int singleWidth; |
74 private int singleHeight; | |
75 private int nextWidth; | |
76 private int nextHeight; | |
77 private boolean isHiDPI = false; | |
78 private int hiDPIWidth; | |
79 private int hiDPIHeight; | |
255 | 80 |
224 | 81 public ReceiverTask(Reader reader, |
275 | 82 IRepaintController repaintController, ClipboardController clipboardController, |
314 | 83 DecodersContainer decoders, final ProtocolContext context, |
275 | 84 TreeRFBProto _rfb) { |
224 | 85 rfb = _rfb; |
86 this.reader = reader; | |
87 this.repaintController = repaintController; | |
88 this.clipboardController = clipboardController; | |
89 this.context = context; | |
90 this.decoders = decoders; | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
176
diff
changeset
|
91 |
224 | 92 Decoder decoder = new ZRLEESender(rfb); |
93 decoders.setDecoderByType(EncodingType.ZLIB, decoder); | |
94 decoders.setDecoderByType(EncodingType.ZRLE, decoder); | |
95 decoders.setDecoderByType(EncodingType.ZRLEE, decoder); | |
96 | |
97 if(!rfb.getCuiVersion()) | |
307 | 98 if (rfb.filterSingleDisplay) { |
353 | 99 renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(), context.getPixelFormat()); |
307 | 100 fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, rfb.getSingleWidth(), rfb.getSingleHeight(), true); |
101 } else { | |
102 renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(), context.getPixelFormat()); | |
103 fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); | |
104 } | |
224 | 105 if(rfb.isTreeManager()) { |
106 fullscreenFbUpdateIncrementalRequest.sendFullScreenRequest(); | |
107 connectionFinished(); | |
314 | 108 if(rfb.checkDelay) { |
109 SendCheckDelay sendCheckDelay = new SendCheckDelay(rfb); | |
110 Thread sendCheckDelayThread = new Thread(sendCheckDelay, "send-check-delay"); | |
111 sendCheckDelayThread.start(); | |
112 } | |
113 if(rfb.fixingSize) { | |
114 timer = new Timer("framebufferUpdate-request-timer", true); | |
115 timer.schedule(new TimerTask() { | |
116 @Override | |
117 public void run() { | |
118 context.setFbWidth(rfb.fixingSizeWidth); | |
119 context.setFbHeight(rfb.fixingSizeHeight); | |
120 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true)); | |
121 } | |
122 }, 0, 100); | |
123 } | |
358 | 124 if(rfb.filterSingleDisplay) { |
125 singleWidth = rfb.getSingleWidth(); | |
126 nextWidth = rfb.getNextWidth(); | |
127 isHiDPI = rfb.setHiDPI(singleWidth, singleHeight, nextWidth); | |
128 } | |
224 | 129 } |
130 } | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
176
diff
changeset
|
131 |
358 | 132 |
133 | |
224 | 134 @Override |
135 public void run() { | |
136 isRunning = true; | |
137 while (isRunning) { | |
138 try { | |
139 if(! rfb.isTreeManager()) { | |
140 // client has 8byte packet sequence number | |
242 | 141 // add serial number flag (4byte) |
142 reader.mark(20+8+4); | |
143 getLost(reader); //check seq consistency | |
224 | 144 } else { |
145 reader.mark(20); | |
146 } | |
147 byte messageId = reader.readByte(); | |
148 switch (messageId) { | |
275 | 149 case FRAMEBUFFER_UPDATE: |
150 // logger.fine("Server message: FramebufferUpdate (0)"); | |
151 framebufferUpdateMessage(); | |
152 break; | |
153 case SET_COLOR_MAP_ENTRIES: | |
154 logger.severe("Server message SetColorMapEntries is not implemented. Skip."); | |
155 setColorMapEntries(); | |
156 break; | |
157 case BELL: | |
158 logger.fine("Server message: Bell"); | |
159 // System.out.print("\0007"); | |
160 // System.out.flush(); | |
161 break; | |
162 case SERVER_CUT_TEXT: | |
163 logger.fine("Server message: CutText (3)"); | |
164 serverCutText(); | |
165 break; | |
166 default: | |
167 logger.severe("Unsupported server message. Id = " + messageId); | |
224 | 168 } |
169 } catch (TransportException e) { | |
347
1f86df6504b7
don't use clearChildrenTransmission()
Miwa Oshiro <oshiro1122@gmail.com>
parents:
345
diff
changeset
|
170 logger.severe("Close session : ReceiverTask : " + e.getMessage()); |
224 | 171 if(!rfb.isTreeManager() && !(rfb.getTerminationType())) { |
332
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
172 System.out.println("death parent node, wait connect new parent node."); |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
173 // close viewer |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
174 ViewerInterface viewer = rfb.getViewer(); |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
175 viewer.setVisible(false); |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
176 try { |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
177 // clean DataInputStream |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
178 reader.close(); |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
179 } catch (TransportException e1) { |
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
180 e1.printStackTrace(); |
224 | 181 } |
182 } | |
183 stopTask(); | |
184 } catch (ProtocolException e) { | |
185 logger.severe(e.getMessage()); | |
186 if (isRunning) { | |
187 context.cleanUpSession(e.getMessage() + "\nConnection closed."); | |
188 } | |
189 stopTask(); | |
190 } catch (CommonException e) { | |
191 logger.severe(e.getMessage()); | |
192 if (isRunning) { | |
193 context.cleanUpSession("Connection closed.."); | |
194 } | |
195 stopTask(); | |
196 } catch (Throwable te) { | |
197 StringWriter sw = new StringWriter(); | |
198 PrintWriter pw = new PrintWriter(sw); | |
199 te.printStackTrace(pw); | |
353 | 200 logger.severe("updateRectangle record failed : " + te.getMessage()); |
224 | 201 if (isRunning) { |
202 context.cleanUpSession(te.getMessage() + "\n" + sw.toString()); | |
203 } | |
204 stopTask(); | |
205 } | |
206 } | |
207 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 |
224 | 209 private void sleep(int i) { |
210 try { | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
211 Thread.sleep(i); |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
212 } catch (InterruptedException e) { |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
213 // nothing. |
332
6a6653b67bd7
fix bug lostChild and change message panel failed connect death node
oc
parents:
331
diff
changeset
|
214 |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
215 } |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
216 } |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
217 |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
218 |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
219 private void setColorMapEntries() throws TransportException { |
224 | 220 reader.readByte(); // padding |
221 reader.readUInt16(); // first color index | |
222 int length = reader.readUInt16(); | |
223 while (length-- > 0) { | |
224 reader.readUInt16(); // R | |
225 reader.readUInt16(); // G | |
226 reader.readUInt16(); // B | |
227 } | |
228 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 |
224 | 230 private void serverCutText() throws TransportException { |
231 reader.readByte(); // padding | |
232 reader.readInt16(); // padding | |
233 int length = reader.readInt32() & Integer.MAX_VALUE; | |
234 clipboardController.updateSystemClipboard(reader.readBytes(length)); | |
235 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 |
353 | 237 public void framebufferUpdateMessage() throws Exception { |
276 | 238 |
336 | 239 try { |
240 reader.readByte(); // padding | |
241 this.numberOfRectangles = reader.readUInt16(); | |
242 if(numberOfRectangles != 1) | |
243 System.out.println("numberofrectangle : " + numberOfRectangles); | |
244 while (numberOfRectangles-- > 0) { | |
245 FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle(); | |
246 rect.fill(reader); | |
247 long time = System.currentTimeMillis(); | |
248 if(rfb.isTreeManager() && rfb.checkDelay) | |
249 System.out.println(time + " : size : " + rect.width * rect.height); | |
250 Decoder decoder = decoders.getDecoderByType(rect.getEncodingType()); | |
251 logger.finest(rect.toString() + (0 == numberOfRectangles ? "\n---" : "")); | |
252 if (decoder != null) { | |
353 | 253 try { |
254 decoder.decode(reader, renderer, rect); // TreeVNC processing here | |
255 if (rfb.getCuiVersion()) continue; | |
358 | 256 if (rfb.filterSingleDisplay) { |
257 if (!isHiDPI) { | |
258 if (rect.x >= rfb.getSingleWidth()) { | |
259 continue; | |
260 } | |
261 } else { | |
262 if (rect.x >= rfb.getHiDPIWidth()) { | |
263 continue; | |
264 } | |
265 } | |
266 } | |
353 | 267 repaintController.repaintBitmap(rect); |
268 } catch (Exception e) { | |
269 throw e; | |
270 } | |
336 | 271 } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) { |
272 RichCursorDecoder.getInstance().decode(reader, renderer, rect); | |
273 if(repaintController!=null) | |
274 repaintController.repaintCursor(); | |
275 } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { | |
276 renderer.decodeCursorPosition(rect); | |
224 | 277 repaintController.repaintCursor(); |
336 | 278 } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE || rect.getEncodingType() == EncodingType.INIT_DATA ) { |
279 fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false); | |
280 rfb.setCuiVersion(false); | |
281 boolean visible = true; | |
282 if (rect.getEncodingType() == EncodingType.INIT_DATA) { | |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
339
diff
changeset
|
283 // VNCServer is changed, initiarize new screen. |
336 | 284 int length = reader.readInt32(); |
285 byte[] initData = new byte[length]; | |
286 reader.read(initData); | |
287 String name = new String(initData, 24, length - 24, "UTF-8"); | |
288 rfb.getContext().setRemoteDesktopName(name); | |
289 rfb.getContext().setInitData(initData); | |
290 repaintController.updateRemoteDesktopName(rfb.getContext()); | |
291 reader.reset(); | |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
339
diff
changeset
|
292 // All children multicastqueue should be discarded hear. |
347
1f86df6504b7
don't use clearChildrenTransmission()
Miwa Oshiro <oshiro1122@gmail.com>
parents:
345
diff
changeset
|
293 // rfb.clearChildrenTransmission(); |
336 | 294 rfb.readSendData(length + 20, reader, null, rect); // size of UpdateRectangleMessage with initData. |
295 short id = (short) rect.x; | |
296 visible = (id != rfb.getId()); | |
297 } | |
298 synchronized (renderer.getLock()) { | |
299 if(!(rfb.getCuiVersion())) | |
300 renderer = repaintController.createRenderer(reader, rect.width, rect.height, context.getPixelFormat()); | |
301 } | |
302 if (rect.getEncodingType() == EncodingType.INIT_DATA) { | |
303 repaintController.setVisible(visible); | |
304 } | |
305 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); | |
306 // repaintController.repaintCursor(); | |
307 } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { | |
308 int checkDelaySize = 24; | |
224 | 309 reader.reset(); |
336 | 310 rfb.readSendData(checkDelaySize, reader, null, rect); |
311 int port = rfb.acceptPort; | |
312 String address = rfb.getMyAddress(); | |
313 sendCheckDelayReply(rect.time, port, address); | |
314 } else if (rect.getEncodingType() == EncodingType.SOUND) { | |
315 // SOUNDを受信した時の処理を | |
316 } else | |
317 throw new CommonException("Unprocessed encoding: " + rect.toString()); | |
318 } | |
319 } catch (UnsupportedEncodingException e) { | |
346 | 320 e.getMessage(); |
336 | 321 e.printStackTrace(); |
322 reader.close(); | |
224 | 323 } |
275 | 324 |
336 | 325 if (rfb.isTreeManager()) { |
326 synchronized (this) { | |
327 if (needSendPixelFormat) { | |
328 needSendPixelFormat = false; | |
329 context.setPixelFormat(pixelFormat); | |
330 context.sendMessage(new SetPixelFormatMessage(pixelFormat)); | |
331 logger.fine("sent: " + pixelFormat); | |
332 context.sendRefreshMessage(); | |
333 logger.fine("sent: nonincremental fb update"); | |
334 } else { | |
335 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), false)); | |
336 } | |
224 | 337 } |
338 } | |
339 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
340 |
234 | 341 private void sendCheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { |
342 context.sendMessage(new CheckDelayReply(time, port, address)); | |
230 | 343 } |
344 | |
224 | 345 public synchronized void queueUpdatePixelFormat(PixelFormat pf) { |
346 pixelFormat = pf; | |
347 needSendPixelFormat = true; | |
348 // context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, 1, 1, false)); | |
349 } | |
350 | |
351 public void stopTask() { | |
352 isRunning = false; | |
353 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354 |
224 | 355 private void connectionFinished() { |
356 rfb.vncConnected(true); | |
357 } | |
358 | |
359 private void getLost(Reader reader) throws Exception { | |
242 | 360 int addSerialNumFlag = reader.readInt32(); |
224 | 361 long num = reader.readInt64(); |
243 | 362 if (addSerialNumFlag == 1) { |
363 rfb.setAddSerialNum(true); | |
364 if(num != ++checkCounter) { | |
365 System.out.println("LostData" + (num - checkCounter)); | |
366 checkCounter = num; | |
367 } | |
224 | 368 } |
369 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
370 } |