Mercurial > hg > Members > riono > TreeVNC_ja_comment
annotate src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java @ 275:0f9b3de45fb2
set main display size.
author | oc |
---|---|
date | Tue, 06 Jan 2015 19:07:27 +0900 |
parents | d3a921d16121 |
children | 0309ea3a4f4e |
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; |
275 | 80 int singleWidth = 0; |
224 | 81 |
255 | 82 |
224 | 83 public ReceiverTask(Reader reader, |
275 | 84 IRepaintController repaintController, ClipboardController clipboardController, |
85 DecodersContainer decoders, ProtocolContext context, | |
86 TreeRFBProto _rfb) { | |
224 | 87 rfb = _rfb; |
88 this.reader = reader; | |
89 this.repaintController = repaintController; | |
90 this.clipboardController = clipboardController; | |
91 this.context = context; | |
92 this.decoders = decoders; | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
176
diff
changeset
|
93 |
224 | 94 Decoder decoder = new ZRLEESender(rfb); |
95 decoders.setDecoderByType(EncodingType.ZLIB, decoder); | |
96 decoders.setDecoderByType(EncodingType.ZRLE, decoder); | |
97 decoders.setDecoderByType(EncodingType.ZRLEE, decoder); | |
98 | |
99 if(!rfb.getCuiVersion()) | |
100 renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(),context.getPixelFormat()); | |
255 | 101 fullscreenFbUpdateIncrementalRequest = new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); |
224 | 102 if(rfb.isTreeManager()) { |
103 fullscreenFbUpdateIncrementalRequest.sendFullScreenRequest(); | |
104 connectionFinished(); | |
105 } | |
106 } | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
176
diff
changeset
|
107 |
224 | 108 @Override |
109 public void run() { | |
110 isRunning = true; | |
111 while (isRunning) { | |
112 try { | |
113 if(! rfb.isTreeManager()) { | |
114 // client has 8byte packet sequence number | |
242 | 115 // add serial number flag (4byte) |
116 reader.mark(20+8+4); | |
117 getLost(reader); //check seq consistency | |
224 | 118 } else { |
119 reader.mark(20); | |
120 } | |
121 byte messageId = reader.readByte(); | |
122 switch (messageId) { | |
275 | 123 case FRAMEBUFFER_UPDATE: |
124 // logger.fine("Server message: FramebufferUpdate (0)"); | |
125 framebufferUpdateMessage(); | |
126 break; | |
127 case SET_COLOR_MAP_ENTRIES: | |
128 logger.severe("Server message SetColorMapEntries is not implemented. Skip."); | |
129 setColorMapEntries(); | |
130 break; | |
131 case BELL: | |
132 logger.fine("Server message: Bell"); | |
133 // System.out.print("\0007"); | |
134 // System.out.flush(); | |
135 break; | |
136 case SERVER_CUT_TEXT: | |
137 logger.fine("Server message: CutText (3)"); | |
138 serverCutText(); | |
139 break; | |
140 default: | |
141 logger.severe("Unsupported server message. Id = " + messageId); | |
224 | 142 } |
143 } catch (TransportException e) { | |
133 | 144 logger.severe("Close session: " + e.getMessage()); |
224 | 145 if(!rfb.isTreeManager() && !(rfb.getTerminationType())) { |
146 System.out.println("task stop"); | |
147 TreeVncProtocol echo = new TreeVncProtocol(rfb.getConnectionParam().getHostName(), rfb.getConnectionParam().getPort()); | |
148 int counter = 3; | |
149 while(counter-- > 0) { | |
150 try { | |
151 if (rfb.isLeader()) { | |
152 echo.lostParent(rfb.getMyAddress(),rfb.getAcceptPort()); | |
153 } | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
154 break; |
133 | 155 } catch (Exception e1) { |
156 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
|
157 sleep(3000); |
133 | 158 } |
224 | 159 } |
160 } | |
161 stopTask(); | |
162 } catch (ProtocolException e) { | |
163 logger.severe(e.getMessage()); | |
164 if (isRunning) { | |
165 context.cleanUpSession(e.getMessage() + "\nConnection closed."); | |
166 } | |
167 stopTask(); | |
168 } catch (CommonException e) { | |
169 logger.severe(e.getMessage()); | |
170 if (isRunning) { | |
171 context.cleanUpSession("Connection closed.."); | |
172 } | |
173 stopTask(); | |
174 } catch (Throwable te) { | |
175 StringWriter sw = new StringWriter(); | |
176 PrintWriter pw = new PrintWriter(sw); | |
177 te.printStackTrace(pw); | |
178 logger.severe(te.getMessage()); | |
179 if (isRunning) { | |
180 context.cleanUpSession(te.getMessage() + "\n" + sw.toString()); | |
181 } | |
182 stopTask(); | |
183 } | |
184 } | |
185 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 |
224 | 187 private void sleep(int i) { |
188 try { | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
189 Thread.sleep(i); |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
190 } catch (InterruptedException e) { |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
191 // nothing. |
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 |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
135
diff
changeset
|
196 private void setColorMapEntries() throws TransportException { |
224 | 197 reader.readByte(); // padding |
198 reader.readUInt16(); // first color index | |
199 int length = reader.readUInt16(); | |
200 while (length-- > 0) { | |
201 reader.readUInt16(); // R | |
202 reader.readUInt16(); // G | |
203 reader.readUInt16(); // B | |
204 } | |
205 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206 |
224 | 207 private void serverCutText() throws TransportException { |
208 reader.readByte(); // padding | |
209 reader.readInt16(); // padding | |
210 int length = reader.readInt32() & Integer.MAX_VALUE; | |
211 clipboardController.updateSystemClipboard(reader.readBytes(length)); | |
212 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 |
224 | 214 public void framebufferUpdateMessage() throws CommonException, UnsupportedEncodingException { |
215 reader.readByte(); // padding | |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
216 |
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
217 this.numberOfRectangles = reader.readUInt16(); |
250 | 218 |
219 if(numberOfRectangles != 1) | |
220 System.out.println("numberofrectangle : " + numberOfRectangles); | |
248
e6abf4b0c92e
add numberOfRectangle in checkDelay
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
246
diff
changeset
|
221 |
275 | 222 if(rfb.isTreeManager() && firstTime) { |
255 | 223 if(rfb.checkDelay) { |
224 SendCheckDelay sendCheckDelay = new SendCheckDelay(rfb); | |
225 Thread sendCheckDelayThread = new Thread(sendCheckDelay, "send-check-delay"); | |
226 sendCheckDelayThread.start(); | |
227 } | |
257 | 228 if(rfb.fixingSize) { |
256 | 229 timer = new Timer(true); |
230 timer.schedule(new TimerTask() { | |
231 @Override | |
232 public void run() { | |
267 | 233 context.setFbWidth(rfb.fixingSizeWidth); |
234 context.setFbHeight(rfb.fixingSizeHeight); | |
256 | 235 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true)); |
236 } | |
237 }, 0, 100); | |
238 } | |
275 | 239 this.firstTime = false; |
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 | |
267 | 254 if(!(rfb.getCuiVersion())) { |
270 | 255 if (rfb.filterSingleDisplay) { |
275 | 256 if (rect.x < rfb.singleWidth) { |
270 | 257 repaintController.repaintBitmap(rect); |
258 } | |
259 } else { | |
260 repaintController.repaintBitmap(rect); | |
261 } | |
267 | 262 } |
224 | 263 } else if (rect.getEncodingType() == EncodingType.RICH_CURSOR) { |
264 RichCursorDecoder.getInstance().decode(reader, renderer, rect); | |
265 if(repaintController!=null) | |
266 repaintController.repaintCursor(); | |
267 } else if (rect.getEncodingType() == EncodingType.CURSOR_POS) { | |
268 renderer.decodeCursorPosition(rect); | |
269 repaintController.repaintCursor(); | |
270 } else if (rect.getEncodingType() == EncodingType.DESKTOP_SIZE || rect.getEncodingType() == EncodingType.INIT_DATA ) { | |
255 | 271 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
|
272 rfb.setCuiVersion(false); |
171 | 273 boolean visible = true; |
164 | 274 if (rect.getEncodingType() == EncodingType.INIT_DATA) { |
224 | 275 int length = reader.readInt32(); |
276 byte[] initData = new byte[length]; | |
277 reader.read(initData); | |
278 String name = new String(initData, 24, length - 24, "UTF-8"); | |
279 rfb.getContext().setRemoteDesktopName(name); | |
280 rfb.getContext().setInitData(initData); | |
281 repaintController.updateRemoteDesktopName(rfb.getContext()); | |
282 reader.reset(); | |
264 | 283 rfb.readSendData(length + 20, reader, null, rect); // size of UpdateRectangleMessage with initData. |
224 | 284 short id = (short) rect.x; |
285 visible = (id != rfb.getId()); | |
164 | 286 } |
171 | 287 synchronized (renderer.getLock()) { |
224 | 288 if(!(rfb.getCuiVersion())) |
255 | 289 renderer = repaintController.createRenderer(reader, rect.width, rect.height, context.getPixelFormat()); |
171 | 290 } |
291 if (rect.getEncodingType() == EncodingType.INIT_DATA) { | |
224 | 292 repaintController.setVisible(visible); |
171 | 293 } |
255 | 294 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, rect.width, rect.height, false)); |
224 | 295 // repaintController.repaintCursor(); |
227
2cb2279ca95c
send checkdelay time.
Miwa Oshiro <e115747@ie.u-ryukyu.ac.jp>
parents:
226
diff
changeset
|
296 } else if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { |
242 | 297 int checkDelaySize = 24; |
229
5eb8aa65f387
fix checkdelay number-of-rectangle, and send checkdelay to lower node.
oc
parents:
228
diff
changeset
|
298 reader.reset(); |
264 | 299 rfb.readSendData(checkDelaySize, reader, null, rect); |
234 | 300 int port = rfb.acceptPort; |
301 String address = rfb.getMyAddress(); | |
302 sendCheckDelayReply(rect.time, port, address); | |
224 | 303 } else |
304 throw new CommonException("Unprocessed encoding: " + rect.toString()); | |
305 } | |
275 | 306 |
239 | 307 if (!rfb.isTreeManager()) { |
275 | 308 return; |
239 | 309 } |
224 | 310 synchronized (this) { |
311 if (needSendPixelFormat) { | |
312 needSendPixelFormat = false; | |
313 context.setPixelFormat(pixelFormat); | |
314 context.sendMessage(new SetPixelFormatMessage(pixelFormat)); | |
315 logger.fine("sent: "+pixelFormat); | |
316 context.sendRefreshMessage(); | |
317 logger.fine("sent: nonincremental fb update"); | |
318 } else { | |
255 | 319 context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), false)); |
224 | 320 } |
321 } | |
322 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
323 |
234 | 324 private void sendCheckDelayReply(long time, int port, String address) throws UnsupportedEncodingException { |
325 context.sendMessage(new CheckDelayReply(time, port, address)); | |
230 | 326 } |
327 | |
224 | 328 public synchronized void queueUpdatePixelFormat(PixelFormat pf) { |
329 pixelFormat = pf; | |
330 needSendPixelFormat = true; | |
331 // context.sendMessage(new FramebufferUpdateRequestMessage(0, 0, 1, 1, false)); | |
332 } | |
333 | |
334 public void stopTask() { | |
335 isRunning = false; | |
336 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
337 |
224 | 338 private void connectionFinished() { |
339 rfb.vncConnected(true); | |
340 } | |
341 | |
342 private void getLost(Reader reader) throws Exception { | |
242 | 343 int addSerialNumFlag = reader.readInt32(); |
224 | 344 long num = reader.readInt64(); |
243 | 345 if (addSerialNumFlag == 1) { |
346 rfb.setAddSerialNum(true); | |
347 if(num != ++checkCounter) { | |
348 System.out.println("LostData" + (num - checkCounter)); | |
349 checkCounter = num; | |
350 } | |
224 | 351 } |
352 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
353 } |