Mercurial > hg > Members > riono > TreeVNC_ja_comment
annotate src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java @ 113:bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 May 2014 23:52:21 +0900 |
parents | 918dc3ee1c79 |
children | 38e461e9b9c9 |
rev | line source |
---|---|
32 | 1 package jp.ac.u_ryukyu.treevnc; |
28 | 2 |
3 import java.io.IOException; | |
4 import java.net.Socket; | |
5 import java.nio.ByteBuffer; | |
109 | 6 import java.nio.ByteOrder; |
28 | 7 import java.util.LinkedList; |
8 import java.util.concurrent.atomic.AtomicInteger; | |
9 | |
35 | 10 import jp.ac.u_ryukyu.treevnc.client.EchoClient; |
28 | 11 import jp.ac.u_ryukyu.treevnc.server.RequestScreenThread; |
94
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
12 import jp.ac.u_ryukyu.treevnc.server.VncProxyService; |
28 | 13 |
14 import com.glavsoft.exceptions.TransportException; | |
107 | 15 import com.glavsoft.rfb.client.ClientToServerMessage; |
96 | 16 import com.glavsoft.rfb.encoding.EncodingType; |
28 | 17 import com.glavsoft.rfb.protocol.Protocol; |
18 import com.glavsoft.rfb.protocol.ProtocolContext; | |
19 import com.glavsoft.transport.Reader; | |
20 import com.glavsoft.transport.Writer; | |
65 | 21 import com.glavsoft.viewer.ViewerImpl; |
28 | 22 |
23 public class MyRfbProto { | |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
24 final static int FramebufferUpdateRequest = 3; |
28 | 25 final static int CheckDelay = 11; |
103 | 26 protected final static int FramebufferUpdate = 0; |
28 | 27 private ProtocolContext context; |
103 | 28 protected final static String versionMsg_3_856 = "RFB 003.856\n"; |
28 | 29 private int clients; |
98 | 30 public MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); |
28 | 31 private RequestScreenThread rThread; |
32 private boolean proxyFlag = true; | |
35 | 33 private EchoClient echo; |
45 | 34 private String proxyAddr; |
60 | 35 public int acceptPort; |
94
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
36 protected boolean readyReconnect = false; |
98 | 37 private boolean cuiVersion; |
107 | 38 private long counter = 0; // packet serial number |
39 private VncProxyService viewer = null; | |
40 | |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
41 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
42 public MyRfbProto() { |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
43 rThread = new RequestScreenThread(this); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
44 } |
107 | 45 |
111 | 46 public void setVncProxy(VncProxyService viewer) { |
107 | 47 this.viewer = viewer; |
48 } | |
28 | 49 |
103 | 50 public boolean isRoot() { |
51 return false; | |
52 } | |
28 | 53 |
54 public void newClient(AcceptThread acceptThread, final Socket newCli, | |
55 final Writer os, final Reader is) throws IOException { | |
56 // createBimgFlag = true; | |
57 // rfb.addSockTmp(newCli); | |
58 // addSock(newCli); | |
59 final int myId = clients; | |
60 final MulticastQueue.Client<LinkedList<ByteBuffer>> c = multicastqueue.newClient(); | |
61 final AtomicInteger writerRunning = new AtomicInteger(); | |
62 writerRunning.set(1); | |
63 /** | |
64 * Timeout thread. If a client is suspended, it has top of queue | |
65 * indefinitely, which caused memory overflow. After the timeout, we | |
66 * poll the queue and discard it. Start long wait if writer is running. | |
67 */ | |
68 final Runnable timer = new Runnable() { | |
69 public void run() { | |
70 int count = 0; | |
71 for (;;) { | |
72 long timeout = 50000 / 8; | |
73 try { | |
74 synchronized (this) { | |
75 int state, flag; | |
76 writerRunning.set(0); | |
77 wait(timeout); | |
78 flag = 0; | |
79 while ((state = writerRunning.get()) == 0) { | |
80 c.poll(); // discard, should be timeout | |
81 count++; | |
82 if (flag == 0) { | |
83 System.out.println("Discarding " + myId | |
84 + " count=" + count); | |
85 flag = 1; | |
86 } | |
87 wait(10); // if this is too short, writer cannot | |
88 // take the poll, if this is too | |
89 // long, memory will overflow... | |
90 } | |
91 if (flag == 1) | |
92 System.out.println("Resuming " + myId | |
93 + " count=" + count); | |
94 if (state != 1) { | |
95 System.out.println("Client died " + myId); | |
96 break; | |
97 } | |
98 } | |
99 } catch (InterruptedException e) { | |
100 } | |
101 } | |
102 } | |
103 }; | |
88 | 104 new Thread(timer, "timer-discard-multicastqueue").start(); |
28 | 105 /** |
107 | 106 * send all incoming from clients to parent. |
28 | 107 */ |
108 final Runnable reader = new Runnable() { | |
107 | 109 |
110 | |
28 | 111 public void run() { |
112 for (;;) { | |
113 try { | |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
114 final byte b[] = new byte[4096]; |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
115 final int c = is.readByte(b); |
28 | 116 if (c <= 0) |
117 throw new IOException(); | |
107 | 118 if (isRoot()) { |
119 if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { | |
120 if (permitChangeScreen()) { | |
109 | 121 ByteBuffer buf = ByteBuffer.wrap(b); |
122 buf.order(ByteOrder.BIG_ENDIAN); | |
123 int length = buf.getInt(4); | |
107 | 124 if (length == 0) |
125 continue; | |
126 String newHostName = new String(b, 8, length); | |
111 | 127 System.out.println("Root server change request :" + newHostName); |
107 | 128 // please remove these numbers. |
129 if (viewer != null) { | |
130 viewer.changeVNCServer(newHostName, 3200, 1980); | |
131 } | |
132 } else { | |
133 continue; | |
134 } | |
135 } | |
110 | 136 } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
137 ClientToServerMessage sc = new ClientToServerMessage() { |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
138 @Override |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
139 public void send(Writer writer) |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
140 throws TransportException { |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
141 writer.write(b,0,c); |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
142 } |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
143 }; |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
144 context.sendMessage(sc); |
107 | 145 } |
28 | 146 // System.out.println("client read "+c); |
89 | 147 } catch (Exception e) { |
28 | 148 try { |
149 writerRunning.set(2); | |
150 os.close(); | |
151 is.close(); | |
36 | 152 break; |
28 | 153 } catch (IOException e1) { |
154 } catch (TransportException e1) { | |
155 e1.printStackTrace(); | |
156 } | |
157 return; | |
158 } | |
159 } | |
160 } | |
107 | 161 |
162 private boolean permitChangeScreen() { | |
109 | 163 return true; |
107 | 164 } |
28 | 165 }; |
166 /** | |
167 * send packets to a client | |
168 */ | |
169 Runnable sender = new Runnable() { | |
170 public void run() { | |
171 writerRunning.set(1); | |
172 try { | |
173 requestThreadNotify(); | |
174 | |
175 /** | |
176 * initial connection of RFB protocol | |
177 */ | |
178 sendRfbVersion(os); | |
179 // readVersionMsg(is); | |
180 readVersionMsg(is, os); | |
181 sendSecurityType(os); | |
182 readSecType(is); | |
183 sendSecResult(os); | |
184 readClientInit(is); | |
185 sendInitData(os); | |
88 | 186 // after this, we discard upward packet. |
187 new Thread(reader, "discard-upward-comm").start(); | |
28 | 188 // writeFramebufferUpdateRequest(0,0, framebufferWidth, |
189 // framebufferHeight, false ); | |
190 for (;;) { | |
191 LinkedList<ByteBuffer> bufs = c.poll(); | |
192 int inputIndex = 0; | |
193 ByteBuffer header = bufs.get(inputIndex); | |
194 if (header == null) | |
195 continue; | |
196 else if (header.get(0) == CheckDelay) { | |
197 writeToClient(os, bufs, inputIndex); | |
198 continue; | |
199 } else if (header.get(0) == FramebufferUpdate) { | |
63 | 200 //System.out.println("client "+ myId); |
28 | 201 } |
202 /* | |
203 * if(i%20==0){ sendDataCheckDelay(); } i++; | |
204 */ | |
205 writeToClient(os, bufs, inputIndex); | |
206 writerRunning.set(1); // yes my client is awaking. | |
207 } | |
89 | 208 } catch (Exception e) { |
28 | 209 try { |
210 writerRunning.set(2); | |
211 os.close(); | |
212 } catch (IOException e1) { | |
213 } | |
214 /* if socket closed cliList.remove(newCli); */ | |
215 } | |
216 } | |
217 | |
218 public void writeToClient(final Writer os, | |
219 LinkedList<ByteBuffer> bufs, int inputIndex) | |
220 throws TransportException { | |
221 while (inputIndex < bufs.size()) { | |
222 ByteBuffer b = bufs.get(inputIndex++); | |
223 os.write(b.array(), b.position(), b.limit()); | |
224 } | |
225 os.flush(); | |
74 | 226 bufs = null; |
227 multicastqueue.heapAvailable(); | |
28 | 228 } |
229 }; | |
230 clients++; | |
88 | 231 new Thread(sender, "writer-to-lower-node").start(); |
28 | 232 |
233 } | |
234 | |
88 | 235 public void requestThreadNotify() { |
28 | 236 rThread.reStart(); |
237 } | |
238 | |
239 private void sendRfbVersion(Writer writer) throws IOException, TransportException { | |
240 // os.write(versionMsg_3_8.getBytes()); | |
54 | 241 writer.write(versionMsg_3_856.getBytes()); |
28 | 242 } |
243 | |
244 private int readVersionMsg(Reader reader, Writer writer) throws IOException, TransportException { | |
245 | |
246 byte[] b = new byte[12]; | |
247 | |
248 reader.readBytes(b); | |
249 | |
250 if ((b[0] != 'R') || (b[1] != 'F') || (b[2] != 'B') || (b[3] != ' ') | |
251 || (b[4] < '0') || (b[4] > '9') || (b[5] < '0') || (b[5] > '9') | |
252 || (b[6] < '0') || (b[6] > '9') || (b[7] != '.') | |
253 || (b[8] < '0') || (b[8] > '9') || (b[9] < '0') || (b[9] > '9') | |
254 || (b[10] < '0') || (b[10] > '9') || (b[11] != '\n')) { | |
255 throw new IOException("this is not an RFB server"); | |
256 } | |
257 | |
258 int rfbMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0'); | |
259 int rfbMinor = (b[8] - '0') * 100 + (b[9] - '0') * 10 + (b[10] - '0'); | |
260 | |
261 if (rfbMajor < 3) { | |
262 throw new IOException( | |
263 "RFB server does not support protocol version 3"); | |
264 } | |
265 | |
266 if (rfbMinor == 855) { | |
267 sendProxyFlag(writer); | |
268 if (proxyFlag) | |
269 sendPortNumber(writer); | |
270 } | |
271 return rfbMinor; | |
272 } | |
45 | 273 |
28 | 274 |
275 private void sendProxyFlag(Writer writer) throws TransportException { | |
276 if (proxyFlag) | |
277 writer.writeInt(1); | |
278 else | |
279 writer.writeInt(0); | |
280 } | |
281 | |
282 private void sendPortNumber(Writer writer) throws TransportException { | |
283 byte[] b = new byte[4]; | |
284 //b = castIntByte(getHost.getPort()); | |
285 b = castIntByte(9999); | |
286 writer.write(b); | |
287 } | |
288 | |
289 private byte[] castIntByte(int len) { | |
290 byte[] b = new byte[4]; | |
291 b[0] = (byte) ((len >>> 24) & 0xFF); | |
292 b[1] = (byte) ((len >>> 16) & 0xFF); | |
293 b[2] = (byte) ((len >>> 8) & 0xFF); | |
294 b[3] = (byte) ((len >>> 0) & 0xFF); | |
295 return b; | |
296 } | |
297 | |
45 | 298 |
28 | 299 private void readSecType(Reader reader) throws TransportException { |
300 byte[] b = new byte[1]; | |
301 reader.read(b); | |
302 } | |
303 | |
304 private void sendSecurityType(Writer os) throws TransportException { | |
305 // number-of-security-types | |
306 os.writeInt(1); | |
307 // security-types | |
308 // 1:None | |
309 os.writeInt(1); | |
310 | |
311 /* | |
312 * os.write(4); os.write(30); os.write(31); os.write(32); os.write(35); | |
313 * os.flush(); | |
314 */ | |
315 } | |
316 | |
317 private void sendSecResult(Writer os) throws TransportException { | |
318 byte[] b = castIntByte(0); | |
319 os.write(b); | |
320 } | |
321 | |
322 private void readClientInit(Reader in) throws TransportException { | |
323 byte[] b = new byte[0]; | |
324 in.readBytes(b); | |
325 } | |
326 | |
85 | 327 byte initData[] = {7, -128, 4, 56, 32, 24, 0, 1, 0, -1, 0, -1, 0, -1, 16, 8, 0, 0, 0, 0, 0, 0, 0, 7, 102, 105, 114, 101, 102, 108, 121}; |
28 | 328 private void sendInitData(Writer os) throws TransportException { |
85 | 329 // In case of "-d" we have no context |
330 if (context != null){ | |
331 os.write(context.getInitData()); | |
332 } else { | |
333 // Send dummy data | |
334 os.write(initData); | |
335 } | |
28 | 336 } |
337 | |
338 public void setProtocolContext(Protocol workingProtocol) { | |
339 context = workingProtocol; | |
340 } | |
29 | 341 |
342 | |
343 public void readSendData(int dataLen, Reader reader) throws TransportException { | |
344 | |
345 } | |
31 | 346 |
347 public Socket accept() throws IOException { | |
348 return null; | |
349 } | |
350 | |
38 | 351 public int selectPort(int port) { |
352 return port; | |
31 | 353 } |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
354 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
355 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
356 public void writeFramebufferUpdateRequest(int x, int y, int w, int h, |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
357 boolean incremental) throws TransportException { |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
358 byte[] b = new byte[10]; |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
359 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
360 b[0] = (byte) FramebufferUpdateRequest; // 3 is FrameBufferUpdateRequest |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
361 b[1] = (byte) (incremental ? 1 : 0); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
362 b[2] = (byte) ((x >> 8) & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
363 b[3] = (byte) (x & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
364 b[4] = (byte) ((y >> 8) & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
365 b[5] = (byte) (y & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
366 b[6] = (byte) ((w >> 8) & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
367 b[7] = (byte) (w & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
368 b[8] = (byte) ((h >> 8) & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
369 b[9] = (byte) (h & 0xff); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
370 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
371 // os.write(b); |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
372 } |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
373 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
374 public void notProxy() { |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
375 proxyFlag = false; |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
376 } |
35 | 377 |
378 public void setEcho(EchoClient _echo) { | |
379 echo = _echo; | |
380 } | |
381 | |
65 | 382 public void setViewer(ViewerImpl v) { |
36 | 383 echo.setViewer(v); |
384 } | |
385 | |
65 | 386 public ViewerImpl getViewer() { |
387 return echo.getViewer(); | |
388 } | |
389 | |
35 | 390 public EchoClient getEcho() { |
391 return echo; | |
392 } | |
43 | 393 |
394 public void setTerminationType(boolean setType) { | |
395 /*nop*/ | |
396 } | |
397 | |
398 public boolean getTerminationType() { | |
399 /*nop*/ | |
400 return true; | |
401 } | |
45 | 402 |
403 public void setProxyAddr(String proxyAddr) { | |
404 this.proxyAddr = proxyAddr; | |
405 } | |
52 | 406 |
407 | |
408 public void close() { | |
102
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
409 // none |
52 | 410 } |
45 | 411 |
60 | 412 public int getAcceptPort() { |
413 return 0; | |
414 } | |
415 | |
61
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
416 public boolean getReadyReconnect() { |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
417 return readyReconnect; |
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
418 } |
65 | 419 |
420 | |
421 public boolean getCuiVersion() { | |
422 return cuiVersion; | |
61
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
60
diff
changeset
|
423 } |
65 | 424 |
425 public void setCuiVersion(boolean flag) { | |
426 cuiVersion = flag; | |
427 } | |
66 | 428 |
429 public void readCheckDelay(Reader reader) throws TransportException { | |
430 | |
431 } | |
432 | |
433 public String getProxyAddr() { | |
434 return proxyAddr; | |
435 } | |
65 | 436 |
94
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
437 public synchronized void setReadyReconnect(boolean ready) { |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
438 readyReconnect = ready; |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
439 if (ready) { |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
440 notifyAll(); |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
441 } |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
442 } |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
443 |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
444 public synchronized void waitForReady(VncProxyService vncProxyService) throws InterruptedException { |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
445 while (!readyReconnect) { |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
446 wait(); |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
447 } |
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
448 } |
96 | 449 |
450 | |
451 public void sendDesktopSizeChange() { | |
452 LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>(); | |
97 | 453 int width = context.getFbWidth(); |
454 int height = context.getFbHeight(); | |
455 desktopSize.add(new UpdateRectangleMessage(0,0, width, height, EncodingType.DESKTOP_SIZE).getMessage()); | |
99 | 456 addSerialNumber(desktopSize); |
96 | 457 multicastqueue.put(desktopSize); |
458 } | |
98 | 459 |
460 | |
461 public void addSerialNumber(LinkedList<ByteBuffer> bufs) { | |
462 ByteBuffer serialNum = multicastqueue.allocate(8); | |
463 serialNum.putLong(counter++); | |
464 serialNum.flip(); | |
465 bufs.addFirst(serialNum); | |
466 } | |
102
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
467 |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
468 |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
469 public void resetDecoder() { |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
470 context.resetDecoder(); |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
471 } |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
472 |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
473 public void stopReceiverTask() { |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
474 if (context!=null) |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
475 context.cleanUpSession(null); |
1f7ee648e1f6
inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
476 } |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
477 |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
478 public String getMyAddress() { |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
479 return echo.getMyAddress(); |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
480 } |
94
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
481 |
28 | 482 } |