annotate src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java @ 511:519d6f94edcc

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