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