Mercurial > hg > Members > riono > TreeVNC_ja_comment
annotate src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 419:7e811f33b99d
Adhoc implement multi display
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 01 Jan 2016 02:39:25 +0900 |
parents | 0543c380308c |
children | 0ad52aac3bc3 |
rev | line source |
---|---|
32 | 1 package jp.ac.u_ryukyu.treevnc; |
28 | 2 |
3 import java.io.IOException; | |
206 | 4 import java.io.OutputStream; |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
5 import java.io.UnsupportedEncodingException; |
291 | 6 import java.net.*; |
28 | 7 import java.nio.ByteBuffer; |
109 | 8 import java.nio.ByteOrder; |
369 | 9 import java.util.Enumeration; |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
10 import java.util.Iterator; |
28 | 11 import java.util.LinkedList; |
12 import java.util.concurrent.atomic.AtomicInteger; | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
13 import java.util.zip.DataFormatException; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
14 import java.util.zip.Deflater; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
15 import java.util.zip.Inflater; |
150 | 16 |
28 | 17 import com.glavsoft.exceptions.TransportException; |
107 | 18 import com.glavsoft.rfb.client.ClientToServerMessage; |
96 | 19 import com.glavsoft.rfb.encoding.EncodingType; |
264 | 20 import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; |
28 | 21 import com.glavsoft.rfb.protocol.Protocol; |
22 import com.glavsoft.rfb.protocol.ProtocolContext; | |
23 import com.glavsoft.transport.Reader; | |
24 import com.glavsoft.transport.Writer; | |
389 | 25 import com.glavsoft.viewer.ConnectionPresenter; |
153 | 26 import com.glavsoft.viewer.ViewerInterface; |
174 | 27 import com.glavsoft.viewer.swing.ConnectionParams; |
28 | 28 |
124 | 29 |
207 | 30 public class TreeRFBProto { |
231 | 31 |
223 | 32 final static int FramebufferUpdateRequest = 3; |
33 final static int CheckDelay = 11; | |
34 protected final static int FramebufferUpdate = 0; | |
35 protected ProtocolContext context; | |
36 private int clients = 0; | |
37 public MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); | |
38 private RequestScreenThread rThread; | |
39 public int acceptPort = 0; | |
174 | 40 private String myAddress; |
223 | 41 private long counter = 0; // packet serial number |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
42 public ServerSocket servSock; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
43 private static final int INFLATE_BUFSIZE = 1024 * 100; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
44 private Inflater inflater = new Inflater(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
45 private Deflater deflater = new Deflater(); |
174 | 46 ViewerInterface viewer; |
341 | 47 private short id = 0; // my tree node id ( = 0 in root ), -1 means no parent |
174 | 48 private TreeVncCommandChannelListener acceptThread; |
49 private TreeRootFinderListener getCast; | |
176 | 50 private CreateConnectionParam cp; |
205
614db20d8fab
try to separate Network management
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
204
diff
changeset
|
51 private TreeVNCNetwork nets = new TreeVNCNetwork(); |
223 | 52 private TreeVncRootSelectionPanel rootSelectionPanel; |
53 private String vncInterface; | |
418
0543c380308c
Move bottleneck Node to outside node list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
54 private TreeManagement treeManager; |
231 | 55 public LinkedList<TreeVNCNode> nodeList; |
267 | 56 |
57 protected boolean readyReconnect = false; | |
58 private boolean cuiVersion; | |
59 private boolean permitChangeScreen = true; | |
60 private boolean leader; | |
61 private boolean hasViewer = false; | |
62 private boolean normalTermination; | |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
63 |
267 | 64 private boolean isTreeManager; |
65 public boolean showTreeNode = false; | |
240 | 66 public boolean checkDelay = false; |
241 | 67 public boolean addSerialNum = false; |
257 | 68 public boolean fixingSize = false; |
267 | 69 public boolean filterSingleDisplay = false; |
257 | 70 public int frameSizeWidth; |
71 public int frameSizeHeight; | |
72 public int fixingSizeWidth; | |
73 public int fixingSizeHeight; | |
74 | |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
75 |
306 | 76 private int singleWidth = 0; |
77 private int singleHeight = 0; | |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
78 private int shareScreenNumber; |
293 | 79 private DatagramSocket socket = null; |
275 | 80 |
306 | 81 private byte[] originalInitData = null; |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
82 private boolean childrenMulticast = true; |
411 | 83 private int retinaScale = 1; |
306 | 84 |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
85 |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
86 private int x; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
87 private int y; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
88 |
418
0543c380308c
Move bottleneck Node to outside node list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
89 |
327
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
90 public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) { |
223 | 91 rThread = new RequestScreenThread(this); |
92 nets.setMyRfb(this); | |
93 this.isTreeManager = isTreeManager; | |
327
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
94 this.viewer = viewer; |
302 | 95 // this.socket = createSocket(); |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
96 startTreeRootFindThread(); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
97 } |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
98 |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
99 public void startTreeRootFindThread() { |
327
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
100 if(isTreeManager()) { |
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
101 getCast = new TreeRootFinderListener(viewer); |
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
102 Thread treeRootFindThread = new Thread(getCast, "tree-root-find-listener"); |
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
103 treeRootFindThread.start(); |
293c35aa902b
add error message, add assure stream close, delete firstTime value in TreeRFBProto.
oc
parents:
325
diff
changeset
|
104 } |
223 | 105 } |
106 | |
107 public boolean isTreeManager() { | |
108 return isTreeManager; | |
109 } | |
207 | 110 |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
111 public void setIsTreeManager(boolean isTreeManager) { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
112 this.isTreeManager = isTreeManager; |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
113 } |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
114 |
378 | 115 public boolean isAddSerialNum() { |
116 return addSerialNum; | |
117 } | |
118 | |
223 | 119 public ProtocolContext getContext() { |
120 return context; | |
121 } | |
122 | |
123 /** | |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
124 * handle new client accept |
223 | 125 * it also handle TreeVNC Command |
126 * @param os | |
127 * @param is | |
128 * @throws IOException | |
129 * @throws TransportException | |
130 */ | |
384 | 131 public void newClient(final Writer os, final Reader is) { |
223 | 132 final int myId = clients; |
133 final MulticastQueue.Client<LinkedList<ByteBuffer>> c = multicastqueue.newClient(); | |
134 final AtomicInteger writerRunning = new AtomicInteger(); | |
135 writerRunning.set(1); | |
136 /** | |
137 * Timeout thread. If a client is suspended, it has top of queue | |
138 * indefinitely, which caused memory overflow. After the timeout, we | |
139 * poll the queue and discard it. Start long wait if writer is running. | |
140 */ | |
141 final Runnable timer = new Runnable() { | |
142 public void run() { | |
143 int count = 0; | |
144 for (;;) { | |
145 long timeout = 50000 / 8; | |
146 try { | |
147 synchronized (this) { | |
148 int state, flag; | |
149 writerRunning.set(0); | |
150 wait(timeout); | |
151 flag = 0; | |
152 while ((state = writerRunning.get()) == 0) { | |
153 c.poll(); // discard, should be timeout | |
154 count++; | |
155 if (flag == 0) { | |
156 System.out.println("Discarding " + myId | |
157 + " count=" + count); | |
158 flag = 1; | |
159 } | |
160 wait(10); // if this is too short, writer cannot | |
161 // take the poll, if this is too | |
162 // long, memory will overflow... | |
163 } | |
164 if (flag == 1) | |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
165 System.out.println("Resuming " + myId + " count=" + count); |
223 | 166 if (state != 1) { |
167 System.out.println("Client died " + myId); | |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
168 System.out.println("task stop"); |
330 | 169 |
170 String rootHostName = null; | |
171 int rootHostPort = 0; | |
172 String myHostName = null; | |
173 int myHostPort = 0; | |
174 | |
385 | 175 if (!isTreeManager) { |
330 | 176 rootHostName = getConnectionParam().getHostName(); |
177 rootHostPort = getConnectionParam().getPort(); | |
178 myHostName = getMyAddress(); | |
179 myHostPort = getAcceptPort(); | |
385 | 180 TreeVncProtocol echo = new TreeVncProtocol(rootHostName, rootHostPort); |
181 echo.lostChild(myHostName, myHostPort, myId); | |
330 | 182 } |
385 | 183 clients--; |
223 | 184 break; |
185 } | |
186 } | |
187 } catch (InterruptedException e) { | |
325 | 188 e.printStackTrace(); |
189 System.out.println("timer thread interrupt."); | |
223 | 190 } |
191 } | |
192 } | |
193 }; | |
194 new Thread(timer, "timer-discard-multicastqueue").start(); | |
195 /** | |
196 * handle command from lower node | |
197 */ | |
198 final Runnable reader = new Runnable() { | |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
199 public void run() { |
223 | 200 for (;;) { |
201 try { | |
202 final byte b[] = new byte[4096]; | |
203 final int c = is.readByte(b); | |
204 if (c <= 0) | |
205 throw new IOException(); | |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
206 // case of root node. |
223 | 207 if (isTreeManager()) { |
208 if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { | |
335 | 209 viewer.setVisible(false); |
223 | 210 if (permitChangeScreen()) { |
211 ByteBuffer buf = ByteBuffer.wrap(b); | |
212 buf.order(ByteOrder.BIG_ENDIAN); | |
325 | 213 buf.get(); // padding |
257 | 214 buf.get(); |
215 short id = buf.getShort(); | |
216 int length = buf.getInt(); | |
325 | 217 if (length == 0) |
218 continue; | |
257 | 219 byte[] byteAddress = new byte[length]; |
220 buf.get(byteAddress); | |
325 | 221 String newHostName = new String(byteAddress, "UTF-8"); |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
222 int x = buf.getInt(); |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
223 int y = buf.getInt(); |
257 | 224 int frameSizeWidth = buf.getInt(); |
225 int frameSizeHeight = buf.getInt(); | |
340 | 226 int port = buf.getInt(); |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
227 int shareScreenNumber = buf.getInt(); |
410 | 228 int scale = buf.getInt(); |
340 | 229 System.out.println("Root server change request :" + newHostName + " : " + port); |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
230 changeVNCServer(viewer, newHostName, port, x, y, frameSizeWidth, frameSizeHeight, shareScreenNumber, scale, id, is, os); |
223 | 231 } else { |
232 continue; | |
233 } | |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
234 } else if (b[0] == ClientToServerMessage.READY_SHARE_SOUND) { |
293 | 235 int rtpPort = selectPort(ConnectionParams.DEFAULT_RTP_PORT); |
236 InetAddress hostname = InetAddress.getLocalHost(); | |
237 ReceiveSound receiveSound = new ReceiveSound(socket); | |
238 Thread receiveSoundThread = new Thread(receiveSound, "receive-sound"); | |
239 receiveSoundThread.start(); | |
230 | 240 } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) { |
241 ByteBuffer buf = ByteBuffer.wrap(b); | |
242 buf.order(ByteOrder.BIG_ENDIAN); | |
234 | 243 buf.getShort(); |
244 Long time = buf.getLong(); | |
245 int port = buf.getInt(); | |
246 int addressLength = buf.getInt(); | |
414
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
247 int dataLen = buf.getInt(); |
234 | 248 byte[] byteAddress = new byte[addressLength]; |
249 buf.get(byteAddress); | |
250 String address = new String(byteAddress, "UTF-8"); | |
235 | 251 int nodeNum = getNodeNum(port, address); |
419
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
252 if (nodeNum != 0) { |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
253 Long delay = System.currentTimeMillis() - time; |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
254 if (delay > 3000) { |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
255 TreeVNCNode deadNode = nodeList.get(nodeNum); |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
256 treeManager.moveLastNodeToLostNodePosition(deadNode.getTreeNum()); |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
257 treeManager.lostNodeConnection(deadNode); |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
258 treeManager.showTreeNode(); |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
259 } |
7e811f33b99d
Adhoc implement multi display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
418
diff
changeset
|
260 System.out.println(System.currentTimeMillis() + " : receive checkDelay : nodeNum" + nodeNum + ", port : " + port + ", address : " + address + ", delay : " + delay + ", size : " + dataLen); |
418
0543c380308c
Move bottleneck Node to outside node list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
261 } |
223 | 262 } |
325 | 263 // case of client node. |
223 | 264 } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) { |
295 | 265 ClientToServerMessage serverChangeRequest = new ClientToServerMessage() { |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
266 @Override |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
267 public void send(Writer writer) |
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
268 throws TransportException { |
325 | 269 writer.write(b, 0, c); |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
270 } |
223 | 271 }; |
295 | 272 context.sendMessage(serverChangeRequest); |
301 | 273 } else if (b[0] == ClientToServerMessage.REQUEST_SINGLE_DISPLAY_SIZE) { |
295 | 274 ClientToServerMessage requestSingeDisplayWidth = new ClientToServerMessage() { |
280
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
275 @Override |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
276 public void send(Writer writer) |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
277 throws TransportException { |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
278 writer.write(b, 0, c); |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
279 } |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
277
diff
changeset
|
280 }; |
295 | 281 context.sendMessage(requestSingeDisplayWidth); |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
282 } else if (b[0] == ClientToServerMessage.READY_SHARE_SOUND) { |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
283 ClientToServerMessage readyShareSound = new ClientToServerMessage() { |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
284 @Override |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
285 public void send(Writer writer) |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
286 throws TransportException { |
325 | 287 writer.write(b, 0, c); |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
288 } |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
289 }; |
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
290 context.sendMessage(readyShareSound); |
230 | 291 } else if (b[0] == ClientToServerMessage.CHECK_DELAY_REPLY) { |
292 ClientToServerMessage checkDelayReply = new ClientToServerMessage() { | |
293 @Override | |
294 public void send(Writer writer) | |
295 throws TransportException { | |
325 | 296 writer.write(b, 0, c); |
230 | 297 } |
298 }; | |
299 context.sendMessage(checkDelayReply); | |
223 | 300 } |
301 } catch (Exception e) { | |
302 try { | |
303 writerRunning.set(2); | |
304 os.close(); | |
305 is.close(); | |
306 break; | |
367 | 307 } catch (Exception e1) { |
308 System.out.println("cannot close ClientToServerMessage "+e1); | |
309 | |
223 | 310 } |
367 | 311 System.out.println("cannot read ClientToServerMessage "+e); |
312 | |
223 | 313 return; |
314 } | |
325 | 315 |
316 /* | |
317 // あとで検討 | |
318 } catch (TransportException e) { | |
319 | |
320 } | |
321 */ | |
223 | 322 } |
323 } | |
324 }; | |
325 /** | |
326 * send packets to a client (one thread for each client ) | |
327 */ | |
328 Runnable sender = new Runnable() { | |
329 public void run() { | |
330 writerRunning.set(1); | |
331 try { | |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
332 requestThreadNotify(); // send full screen request via fullScreenRequestThread |
384 | 333 |
223 | 334 // after this, we discard upward packet. |
239 | 335 new Thread(reader, "upward-packet-processing").start(); |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
336 |
223 | 337 for (;;) { |
338 LinkedList<ByteBuffer> bufs = c.poll(); | |
339 int inputIndex = 0; | |
340 ByteBuffer header = bufs.get(inputIndex); | |
341 if (header == null) | |
342 continue; | |
343 writeToClient(os, bufs, inputIndex); | |
344 writerRunning.set(1); // yes my client is awaking. | |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
345 if (!childrenMulticast) { |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
346 for (;;) { |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
347 LinkedList<ByteBuffer> flag = c.poll(); |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
348 if (flag.size() == 0) { |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
349 break; |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
350 } |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
351 } |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
352 } |
223 | 353 } |
354 } catch (Exception e) { | |
355 try { | |
356 writerRunning.set(2); | |
357 os.close(); | |
358 } catch (IOException e1) { | |
359 System.out.println("root writer close faild :" + e1); | |
360 } | |
361 System.out.println("root writer faild :" + e); | |
362 /* if socket closed cliList.remove(newCli); */ | |
363 } | |
364 } | |
365 public void writeToClient(final Writer os, | |
366 LinkedList<ByteBuffer> bufs, int inputIndex) | |
367 throws TransportException { | |
354 | 368 while (inputIndex < bufs.size()) { |
223 | 369 ByteBuffer b = bufs.get(inputIndex++); |
370 os.write(b.array(), b.position(), b.limit()); | |
371 } | |
372 os.flush(); | |
373 multicastqueue.heapAvailable(); | |
374 } | |
375 }; | |
376 clients++; | |
377 new Thread(sender, "writer-to-lower-node").start(); | |
378 } | |
157
7cea8789387b
thread base command listening loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
153
diff
changeset
|
379 |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
380 public boolean permitChangeScreen() { |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
381 return permitChangeScreen; |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
382 } |
223 | 383 |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
384 |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
385 public void setPermitChangeScreen(boolean v) { |
223 | 386 permitChangeScreen = v; |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
120
diff
changeset
|
387 } |
223 | 388 |
389 public void requestThreadNotify() { | |
390 rThread.reStart(); | |
391 } | |
392 | |
393 | |
28 | 394 public void setProtocolContext(Protocol workingProtocol) { |
395 context = workingProtocol; | |
396 } | |
29 | 397 |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
398 public Socket accept() throws IOException { |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
399 return servSock.accept(); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
400 } |
31 | 401 |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
402 public int selectPort(int p) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
403 int port = p; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
404 while (true) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
405 try { |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
406 servSock = new ServerSocket(port); |
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
407 acceptPort = port; |
181 | 408 myAddress = "127.0.0.1"; |
207 | 409 nets.getNetworkInterfaces(); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
410 break; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
411 } catch (BindException e) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
412 port++; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
413 continue; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
414 } catch (IOException e) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
415 |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
416 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
417 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
418 System.out.println("accept port = " + port); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
419 return port; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
420 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
421 |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
422 |
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
423 |
331
42fcc9419498
add error message, add lostParent case by fail to connectTo.
oc
parents:
330
diff
changeset
|
424 public void writeFramebufferUpdateRequest(int x, int y, int w, int h, boolean incremental) { |
223 | 425 byte[] b = new byte[10]; |
426 | |
427 b[0] = (byte) FramebufferUpdateRequest; // 3 is FrameBufferUpdateRequest | |
428 b[1] = (byte) (incremental ? 1 : 0); | |
429 b[2] = (byte) ((x >> 8) & 0xff); | |
430 b[3] = (byte) (x & 0xff); | |
431 b[4] = (byte) ((y >> 8) & 0xff); | |
432 b[5] = (byte) (y & 0xff); | |
433 b[6] = (byte) ((w >> 8) & 0xff); | |
434 b[7] = (byte) (w & 0xff); | |
435 b[8] = (byte) ((h >> 8) & 0xff); | |
436 b[9] = (byte) (h & 0xff); | |
437 } | |
33
9d3478d11d3b
Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
438 |
223 | 439 public void setViewer(ViewerInterface v) { |
440 viewer = v; | |
441 } | |
442 | |
443 public ViewerInterface getViewer() { | |
444 return viewer; | |
445 } | |
446 | |
447 | |
448 void sendInitData(OutputStream os) throws IOException { | |
449 os.write(context.getInitData()); | |
450 } | |
451 | |
452 | |
453 public void setTerminationType(boolean setType) { | |
454 normalTermination = setType; | |
455 } | |
456 | |
457 public boolean getTerminationType() { | |
458 return normalTermination; | |
459 } | |
43 | 460 |
206 | 461 |
223 | 462 public void addHostToSelectionPanel(int port, String hostname,String myHostName) { |
463 if (rootSelectionPanel != null) { | |
464 rootSelectionPanel.checkBox(Integer.toString(port) + ":" + hostname + ":" + myHostName); | |
465 rootSelectionPanel.setButton(); | |
384 | 466 rootSelectionPanel.visible(); |
223 | 467 } |
468 } | |
43 | 469 |
399
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
470 public void createRootSelectionPanel(CreateConnectionParam cp, FindRoot getBcast) { |
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
471 rootSelectionPanel = new TreeVncRootSelectionPanel(getBcast); |
223 | 472 rootSelectionPanel.setCp(cp); |
399
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
473 rootSelectionPanel.visible(); |
223 | 474 } |
475 | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
476 public void close() { |
223 | 477 // none |
478 } | |
479 | |
480 public int getAcceptPort() { | |
481 return acceptPort; | |
482 } | |
483 | |
484 public boolean getReadyReconnect() { | |
485 return readyReconnect; | |
486 } | |
65 | 487 |
488 | |
223 | 489 public boolean getCuiVersion() { |
490 return cuiVersion; | |
384 | 491 } |
66 | 492 |
223 | 493 public void setCuiVersion(boolean flag) { |
494 cuiVersion = flag; | |
495 } | |
496 | |
497 public void readCheckDelay(Reader reader) throws TransportException { | |
498 | |
499 } | |
134
128cce60c43c
where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
500 |
223 | 501 public synchronized void vncConnected(boolean ready) { |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
502 enableChildrenTransmission(); |
369 | 503 readyReconnect = ready; |
504 if (ready) { | |
505 notifyAll(); | |
223 | 506 } |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
507 } |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
508 |
369 | 509 public void printNetworkInterface() { |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
510 Socket vncSocket = viewer.getVNCSocket(); |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
511 NetworkInterface ni = nets.getInterface(vncSocket); |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
512 if (ni!=null) { |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
513 vncInterface = ni.getName(); |
369 | 514 System.out.print("VNCNetworkInterface :" + vncInterface); |
370 | 515 if(false) { |
516 Enumeration<InetAddress> addresses = ni.getInetAddresses(); | |
517 while (addresses.hasMoreElements()) { | |
518 InetAddress adr = addresses.nextElement(); | |
519 System.out.print(" " + adr); | |
520 } | |
369 | 521 } |
522 System.out.println(); | |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
523 } |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
524 } |
94
75879c316796
synchronized wait for Rfb initialization in change server.
oc
parents:
89
diff
changeset
|
525 |
223 | 526 public void sendDesktopSizeChange(short id) { |
527 LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>(); | |
528 int width = context.getFbWidth(); | |
529 int height = context.getFbHeight(); | |
304 | 530 if (filterSingleDisplay) { |
353 | 531 originalInitData = createOriginalInitData(singleWidth, singleHeight, context.getRemoteDesktopName()); |
350 | 532 // desktopSize.add(new ChengeDesktopSize(singleWidth, singleHeight, EncodingType.INIT_DATA, originalInitData, id).getMessage()); |
533 desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); | |
305 | 534 } else { |
535 desktopSize.add(new ChengeDesktopSize(width, height, EncodingType.INIT_DATA, context.getInitData(), id).getMessage()); | |
304 | 536 } |
380 | 537 if (addSerialNum) { |
538 addSerialNumber(desktopSize); | |
539 } | |
223 | 540 multicastqueue.put(desktopSize); |
541 } | |
98 | 542 |
306 | 543 public byte[] createOriginalInitData(int singleWidth, int singleHeight, String remoteDesktopName) { |
544 TreeVncCommandChannelListener treeVncCommandChannelListener = new TreeVncCommandChannelListener(this, acceptPort); | |
545 byte[] originalInitData = treeVncCommandChannelListener.createOriginalInitData(singleWidth, singleHeight, remoteDesktopName); | |
546 return originalInitData; | |
547 } | |
548 | |
223 | 549 public void addSerialNumber(LinkedList<ByteBuffer> bufs) { |
242 | 550 ByteBuffer serialNum = multicastqueue.allocate(4+8); // addSerialNum flag + SerialNum |
380 | 551 serialNum.putInt(1); |
223 | 552 serialNum.putLong(counter++); |
553 serialNum.flip(); | |
554 bufs.addFirst(serialNum); | |
555 } | |
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
|
556 |
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
|
557 |
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
|
558 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
|
559 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
|
560 } |
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
|
561 |
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
|
562 public void stopReceiverTask() { |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
563 if (context!=null) { |
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
|
564 context.cleanUpSession(null); |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
565 context.getRfb().clearChildrenTransmission(); |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
566 } |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
567 // cleanup zlib decoder for new VNCServer |
202 | 568 if (isTreeManager()) |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
569 inflater = new Inflater(); |
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
|
570 } |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
571 |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
572 public void clearChildrenTransmission() { |
355 | 573 // discarding does not work now. |
574 | |
575 /* | |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
576 // set discard flag |
354 | 577 childrenMulticast = false; |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
578 // put gurd erement to restart multicastqueue. |
354 | 579 multicastqueue.put(new LinkedList<ByteBuffer>()); |
355 | 580 */ |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
581 } |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
582 |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
583 public void enableChildrenTransmission() { |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
584 // a child senderTask may skip this flag |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
585 // durling write waiting. in this case, remaining bufferes are sent. |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
586 childrenMulticast = true; |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
587 } |
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
588 |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
589 public String getMyAddress() { |
174 | 590 return myAddress; |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
591 } |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
592 |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
593 /** |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
594 * gzip byte arrays |
384 | 595 * |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
596 * @param deflater |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
597 * @param inputs |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
598 * byte data[] |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
599 * @param inputIndex |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
600 * @param outputs |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
601 * byte data[] |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
602 * @return byte length in last byte array |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
603 * @throws IOException |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
604 */ |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
605 public int zip(Deflater deflater, LinkedList<ByteBuffer> inputs, |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
606 int inputIndex, LinkedList<ByteBuffer> outputs) throws IOException { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
607 int len = 0; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
608 ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
609 while (inputIndex < inputs.size()) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
610 ByteBuffer b1 = inputs.get(inputIndex++); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
611 deflater.setInput(b1.array(), b1.position(), b1.remaining()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
612 /** |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
613 * If we finish() stream and reset() it, Deflater start new gzip |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
614 * stream, this makes continuous zlib reader unhappy. if we remove |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
615 * finish(), Deflater.deflate() never flushes its output. The |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
616 * original zlib deflate has flush flag. I'm pretty sure this a kind |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
617 * of bug of Java library. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
618 */ |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
619 if (inputIndex == inputs.size()) |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
620 deflater.finish(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
621 int len1 = 0; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
622 do { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
623 len1 = deflater.deflate(c1.array(), c1.position(), |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
624 c1.remaining()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
625 if (len1 > 0) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
626 len += len1; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
627 c1.position(c1.position() + len1); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
628 if (c1.remaining() == 0) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
629 c1.flip(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
630 outputs.addLast(c1); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
631 c1 = multicastqueue.allocate(INFLATE_BUFSIZE); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
632 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
633 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
634 } while (len1 > 0 || !deflater.needsInput()); // &&!deflater.finished()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
635 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
636 if (c1.position() != 0) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
637 c1.flip(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
638 outputs.addLast(c1); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
639 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
640 deflater.reset(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
641 return len; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
642 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
643 |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
644 /** |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
645 * gunzip byte arrays |
384 | 646 * |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
647 * @param inflater |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
648 * @param inputs |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
649 * byte data[] |
182 | 650 * @param bytes |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
651 * byte data[] |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
652 * @return number of total bytes |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
653 * @throws IOException |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
654 */ |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
655 public int unzip(Inflater inflater, LinkedList<ByteBuffer> inputs, |
335 | 656 int inputIndex, byte[] bytes, int bufSize) throws DataFormatException { |
182 | 657 int position = 0; |
658 int limit = bytes.length; | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
659 while (inputIndex < inputs.size()) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
660 ByteBuffer input = inputs.get(inputIndex++); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
661 inflater.setInput(input.array(), input.position(), input.limit()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
662 // if (inputIndex==inputs.size()) if inflater/deflater has symmetry, |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
663 // we need this |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
664 // inflater.end(); but this won't work |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
665 do { |
318 | 666 int len0; |
667 len0 = inflater.inflate(bytes, position, limit-position); | |
668 if (len0 > 0) { | |
669 position += len0; | |
670 if (position > limit) throw new DataFormatException(); | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
671 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
672 } while (!inflater.needsInput()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
673 } |
182 | 674 return position; |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
675 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
676 |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
677 /** |
345
47e351909227
add stop children sender when change server.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
342
diff
changeset
|
678 * Multicast framebufferUpdate to children. |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
679 * read FrameBuffferUpdate. If it is ZLE, make it ZLEE which is self contained compressed packet. |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
680 * put the packet to the multicastqueue. Then normal rendering engine read the same stream using is.reset(). |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
681 * @param dataLen |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
682 * @param reader |
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
683 * @throws TransportException |
384 | 684 * @throws UnsupportedEncodingException |
135
ada4d850a820
lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
134
diff
changeset
|
685 */ |
264 | 686 public void readSendData(int dataLen, Reader reader, byte[] bytes, FramebufferUpdateRectangle rect) |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
687 throws TransportException, UnsupportedEncodingException { |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
688 LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); |
414
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
689 int headerLen = rect.getEncodingType() == EncodingType.CHECK_DELAY ? 24 : 16; |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
690 ByteBuffer header = multicastqueue.allocate(headerLen); |
242 | 691 ByteBuffer serial = multicastqueue.allocate(4+8); |
378 | 692 if (!isTreeManager() && addSerialNum) { |
242 | 693 reader.readBytes(serial.array(),0,4+8); |
694 serial.limit(4+8); | |
182 | 695 } |
185 | 696 reader.mark(dataLen); |
414
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
697 reader.readBytes(header.array(), 0, headerLen); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
698 header.limit(headerLen); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
699 if (header.get(0) == FramebufferUpdate) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
700 int encoding = header.getInt(12); |
384 | 701 |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
702 if (encoding == EncodingType.ZRLE.getId() |
229
5eb8aa65f387
fix checkdelay number-of-rectangle, and send checkdelay to lower node.
oc
parents:
227
diff
changeset
|
703 || encoding == EncodingType.ZLIB.getId()) { |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
704 // recompress into ZREE |
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
705 // uncompressed result is remain in bytes |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
706 ByteBuffer len = multicastqueue.allocate(4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
707 reader.readBytes(len.array(), 0, 4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
708 len.limit(4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
709 ByteBuffer inputData = multicastqueue.allocate(dataLen - 20); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
710 reader.readBytes(inputData.array(), 0, inputData.capacity()); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
711 inputData.limit(dataLen - 20); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
712 LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
713 inputs.add(inputData); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
714 header.putInt(12, EncodingType.ZRLEE.getId()); // means |
223 | 715 // recompress |
716 // every time | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
717 // using new Deflecter every time is incompatible with the |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
718 // protocol, clients have to be modified. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
719 Deflater nDeflater = deflater; // new Deflater(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
720 LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>(); |
380 | 721 try { |
182 | 722 unzip(inflater, inputs, 0, bytes, INFLATE_BUFSIZE); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
723 // dump32(inputs); |
182 | 724 out.add(ByteBuffer.wrap(bytes)); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
725 int len2 = zip(nDeflater, out, 0, bufs); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
726 ByteBuffer blen = multicastqueue.allocate(4); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
727 blen.putInt(len2); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
728 blen.flip(); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
729 bufs.addFirst(blen); |
415
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
730 if (checkDelay) { |
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
731 bufs = createCheckDelayHeader(bufs, header); |
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
732 } else { |
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
733 bufs.addFirst(header); |
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
734 } |
380 | 735 if (addSerialNum) { |
736 addSerialNumber(bufs); | |
737 } | |
270 | 738 if (filterSingleDisplay) { |
275 | 739 if (rect.x < singleWidth) { |
270 | 740 multicastqueue.put(bufs); |
741 } | |
742 } else { | |
743 multicastqueue.put(bufs); | |
744 } | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
745 } catch (IOException e) { |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
746 throw new TransportException(e); |
335 | 747 } catch (DataFormatException e) { |
748 throw new TransportException(e); | |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
749 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
750 return; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
751 } |
233 | 752 |
186
f76ee760c2d2
dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
185
diff
changeset
|
753 // ZRLEE is already compressed |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
754 bufs.add(header); |
380 | 755 if (addSerialNum) { |
756 this.addSerialNumber(bufs); | |
757 } | |
414
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
758 if (dataLen > headerLen) { |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
759 ByteBuffer b = multicastqueue.allocate(dataLen - headerLen); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
760 reader.readBytes(b.array(), 0, dataLen - headerLen); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
761 b.limit(dataLen - headerLen); |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
762 bufs.add(b); |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
763 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
764 multicastqueue.put(bufs); |
233 | 765 |
118
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
766 return; |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
767 } |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
768 // It may be compressed. We can inflate here to avoid repeating clients |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
769 // decompressing here, |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
770 // but it may generate too many large data. It is better to do it in |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
771 // each client. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
772 // But we have do inflation for all input data, so we have to do it |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
773 // here. |
38e461e9b9c9
remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
113
diff
changeset
|
774 } |
124 | 775 |
415
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
776 public LinkedList<ByteBuffer> createCheckDelayHeader(LinkedList<ByteBuffer> checkDelay, ByteBuffer header) { |
414
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
777 int x = (int)header.getShort(4); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
778 int y = (int)header.getShort(6); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
779 int width = (int)header.getShort(8); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
780 int height = (int)header.getShort(10); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
781 long time = System.currentTimeMillis(); |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
782 checkDelay.addFirst(new CheckDelay(x, y, width, height, time, EncodingType.CHECK_DELAY).getMessage()); |
415
5c3635d6ab3c
Send Check_Delay packet if checkDelay flag is true
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
414
diff
changeset
|
783 return checkDelay; |
414
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
784 } |
3af5f4af2d63
Send data size for checkDelay
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
785 |
223 | 786 public void setId(short id) { |
787 this.id = id; | |
788 } | |
169 | 789 |
223 | 790 public short getId() { |
791 return id; | |
792 } | |
169 | 793 |
174 | 794 public void setMyAddress(String myHostName) { |
795 this.myAddress = myHostName; | |
223 | 796 |
174 | 797 } |
798 | |
799 public void setLeader(boolean leader) { | |
800 this.leader = leader; | |
801 } | |
802 | |
803 public boolean isLeader() { | |
804 return leader; | |
805 } | |
806 | |
203 | 807 public void setTreeManager(String intf, TreeManagement clients) { |
223 | 808 nets.setTreeManager(intf, clients); |
174 | 809 } |
223 | 810 |
203 | 811 public TreeManagement getTreeManager(String intf) { |
418
0543c380308c
Move bottleneck Node to outside node list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
812 this.treeManager = nets.getTreeManager(intf); |
0543c380308c
Move bottleneck Node to outside node list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
813 this.nodeList = treeManager.getList(); |
0543c380308c
Move bottleneck Node to outside node list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
814 return treeManager; |
174 | 815 } |
816 | |
817 /** | |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
287
diff
changeset
|
818 * change VNCServer is called when host change. |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
819 * @param vncProxyService |
174 | 820 * @param hostName |
821 * HostAddress | |
359 | 822 * @param width |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
823 * FrameWidth |
359 | 824 * @param height |
382 | 825 * FrameHeight |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
826 * @param shareScreenNumber |
351 | 827 * @param newVNCServerId |
382 | 828 * @param is |
829 * @param os | |
174 | 830 */ |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
831 public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int port, int x, int y, int width, int height, int shareScreenNumber, int scale, short newVNCServerId, Reader is, Writer os) |
325 | 832 throws IOException { |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
833 this.x = x; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
834 this.y = y; |
359 | 835 this.frameSizeWidth = width; |
836 this.frameSizeHeight = height; | |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
837 this.shareScreenNumber = shareScreenNumber; |
410 | 838 this.singleWidth = frameSizeWidth; |
839 this.singleHeight = frameSizeHeight; | |
840 this.retinaScale = scale; | |
351 | 841 if (newVNCServerId == -1) { |
339
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
842 // change to the tree vnc root on other network. |
383 | 843 vncProxyService.changeToDirectConnectedServer(hostName, is, os); |
339
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
844 return; |
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
845 } |
342 | 846 // serverChangeの処理 |
369 | 847 vncProxyService.inhelitClients(vncProxyService, hostName, newVNCServerId); |
317 | 848 // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary |
322 | 849 // stop reader stop |
174 | 850 } |
851 | |
852 /** | |
853 * start accepting children | |
854 * run rootFinderListener if necessary | |
855 */ | |
176 | 856 public void createConnectionAndStart(ViewerInterface v) { |
223 | 857 selectPort(ConnectionParams.DEFAULT_VNC_ROOT); |
176 | 858 acceptThread = new TreeVncCommandChannelListener(this, getAcceptPort()); |
223 | 859 Thread thread = new Thread(acceptThread, "TreeVNC-accept"); |
860 thread.start(); | |
176 | 861 } |
862 | |
174 | 863 public TreeVncCommandChannelListener getAcceptThread() { |
864 return acceptThread; | |
865 } | |
866 | |
176 | 867 public void setConnectionParam(CreateConnectionParam createConnectionParam) { |
868 cp = createConnectionParam; | |
869 } | |
870 | |
871 public CreateConnectionParam getConnectionParam() { | |
872 return cp; | |
873 } | |
874 | |
178
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
875 public boolean hasViewer() { |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
876 return hasViewer; |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
877 } |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
878 |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
879 public void setHasViewer(boolean b) { |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
880 hasViewer = b; |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
881 } |
34b7558aeffa
remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
177
diff
changeset
|
882 |
223 | 883 public void setShowTree(boolean showTree) { |
240 | 884 this.showTreeNode = showTree; |
885 } | |
886 | |
887 public void setCheckDelay(boolean checkDelay) { | |
888 this.checkDelay = checkDelay; | |
223 | 889 } |
194 | 890 |
241 | 891 public void setAddSerialNum(boolean addSerialNum) { |
892 this.addSerialNum = addSerialNum; | |
893 } | |
894 | |
235 | 895 public int getNodeNum(int port, String address) { |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
896 int nodeNum = 0; |
384 | 897 |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
898 for (Iterator<TreeVNCNode> i = nodeList.iterator(); i.hasNext();) { |
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
899 TreeVNCNode tvn = (TreeVNCNode)i.next(); |
235 | 900 if (port == tvn.port && address.equals(tvn.hostname)) { |
901 nodeNum = tvn.treeNum; | |
902 return nodeNum; | |
903 } | |
232
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
904 } |
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
905 return nodeNum; |
6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
oc
parents:
231
diff
changeset
|
906 } |
241 | 907 |
257 | 908 public void setFixingSize(boolean fixingSize) { |
909 this.fixingSize = fixingSize; | |
256 | 910 } |
267 | 911 |
912 public void setFilterSingleDisplay(boolean filterSingleDisplay) { | |
913 this.filterSingleDisplay = filterSingleDisplay; | |
914 } | |
281 | 915 |
293 | 916 private DatagramSocket createSocket() { |
917 | |
918 try { | |
919 if (socket == null) { | |
920 this.socket = new DatagramSocket(ConnectionParams.DEFAULT_RTP_PORT, InetAddress.getLocalHost()); | |
921 } | |
922 } catch (SocketException e) { | |
923 e.printStackTrace(); | |
924 } catch (UnknownHostException e) { | |
925 e.printStackTrace(); | |
926 } | |
927 return socket; | |
928 } | |
306 | 929 |
930 public void setSingleDisplaySize(int singleWidth, int singleHeight) { | |
931 this.singleWidth = singleWidth; | |
932 this.singleHeight = singleHeight; | |
933 } | |
934 | |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
935 public int getX() { |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
936 return x; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
937 } |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
938 |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
939 public int getY() { |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
940 return y; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
941 } |
358 | 942 |
306 | 943 public int getSingleWidth() { |
944 return singleWidth; | |
945 } | |
946 | |
947 public int getSingleHeight() { | |
948 return singleHeight; | |
949 } | |
339
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
950 |
405
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
951 public int getShareScreenNumber() { |
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
952 return shareScreenNumber; |
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
953 } |
cdab1354e227
Add multiscreen Share Filtering flag
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
954 |
410 | 955 |
956 public int getRetinaScale() { | |
957 return retinaScale; | |
958 } | |
959 | |
960 | |
339
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
961 public boolean hasParent() { |
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
962 return id != -1; |
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
335
diff
changeset
|
963 } |
384 | 964 |
965 /** | |
966 * server change to directed connected server | |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
394
diff
changeset
|
967 * server maybe on the different network |
384 | 968 * so can not in whereToConnect message |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
394
diff
changeset
|
969 * reuse dynamic connect socket us a new client |
384 | 970 * reother server exchange socket when serverChangeRequest with id -1 |
971 * @param previousReader | |
972 * @param previousWriter | |
973 */ | |
974 public void exchangeDirectConnectedServer(Reader previousReader, Writer previousWriter) { | |
975 String adr = viewer.getRfb().getMyAddress(); | |
410 | 976 int scale = viewer.getRfb().getRetinaScale(); |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
977 int x = 0; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
978 int y = 0; |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
415
diff
changeset
|
979 ScreenChangeRequest scr = new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, (short) -1, x, y, singleWidth, singleHeight, shareScreenNumber, scale); |
384 | 980 try { |
981 scr.send(previousWriter); | |
982 } catch (TransportException e) { | |
983 e.printStackTrace(); | |
984 return; | |
985 } | |
986 newClient(previousWriter, previousReader); | |
987 } | |
389 | 988 |
989 /** | |
990 * Requested server is connected. stop old connection, replace old connection parameter such as | |
991 * context (PROTOCOL) | |
992 * start new connection and send INIT_DATA | |
993 * @param workingProtocol | |
994 * @param connectionPresenter | |
995 */ | |
996 public synchronized void newVNCConnection(Protocol workingProtocol, ConnectionPresenter connectionPresenter) { | |
997 ProtocolContext previousContext = getContext(); | |
998 stopReceiverTask(); | |
999 setProtocolContext(workingProtocol); | |
1000 connectionPresenter.viewer.setConnectionPresenter(connectionPresenter); | |
1001 connectionPresenter.viewer.getConnectionPresenter().addModel("ConnectionParamsModel", connectionPresenter.getConnectionParams()); | |
1002 if (previousContext != null && isTreeManager() && hasParent()) { | |
1003 Reader previousReader = previousContext.getReader(); | |
1004 Writer previousWriter = previousContext.getWriter(); | |
1005 exchangeDirectConnectedServer(previousReader, previousWriter); | |
1006 } | |
1007 enableChildrenTransmission(); | |
1008 printNetworkInterface(); | |
1009 sendDesktopSizeChange(connectionPresenter.getReconnectingId()); | |
1010 } | |
412 | 1011 |
1012 public void sendErrorAnnounce(short reconnectingId, String message) { | |
1013 LinkedList<ByteBuffer> errorAnnounce = new LinkedList<ByteBuffer>(); | |
1014 errorAnnounce.add(new ChildNodeAnnounce(EncodingType.ERROR_ANNOUNCE, message.getBytes(), reconnectingId).getMessage()); | |
1015 if (addSerialNum) { | |
1016 addSerialNumber(errorAnnounce); | |
1017 } | |
1018 multicastqueue.put(errorAnnounce); | |
1019 } | |
240 | 1020 } |