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