annotate src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java @ 188:f176bffcdc4a

add showTreeNode option.
author oc
date Tue, 24 Jun 2014 16:49:29 +0900
parents b62a16548800
children 971b4ea361e8
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
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
3 import java.io.IOException;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
4 import java.net.BindException;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
5 import java.net.ServerSocket;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
6 import java.net.Socket;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
7 import java.net.UnknownHostException;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
8 import java.nio.ByteBuffer;
109
457f9dfbf7ce minor fix.
oc
parents: 107
diff changeset
9 import java.nio.ByteOrder;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
10 import java.util.LinkedList;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
11 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
12 import java.util.zip.DataFormatException;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
13 import java.util.zip.Deflater;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
14 import java.util.zip.Inflater;
150
925fb2090282 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
15
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
16 import jp.ac.u_ryukyu.treevnc.server.RequestScreenThread;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
17 import jp.ac.u_ryukyu.treevnc.server.TreeManagement;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
18 import jp.ac.u_ryukyu.treevnc.server.TreeRootFinderListener;
150
925fb2090282 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
19
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
20 import com.glavsoft.exceptions.TransportException;
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
21 import com.glavsoft.rfb.client.ClientToServerMessage;
96
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
22 import com.glavsoft.rfb.encoding.EncodingType;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
23 import com.glavsoft.rfb.protocol.Protocol;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
24 import com.glavsoft.rfb.protocol.ProtocolContext;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
25 import com.glavsoft.transport.Reader;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
26 import com.glavsoft.transport.Writer;
153
e68dfd1972ac fix bad names.
oc
parents: 150
diff changeset
27 import com.glavsoft.viewer.ViewerInterface;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
28 import com.glavsoft.viewer.swing.ConnectionParams;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
29
124
214d4f206431 add TreeVNC command number.
oc
parents: 123
diff changeset
30
120
c1b14cef2704 MyRfb fix done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
31 public abstract class MyRfbProto {
33
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
32 final static int FramebufferUpdateRequest = 3;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
33 final static int CheckDelay = 11;
103
84f254d8bde4 remove isinstaceof
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
34 protected final static int FramebufferUpdate = 0;
153
e68dfd1972ac fix bad names.
oc
parents: 150
diff changeset
35 protected ProtocolContext context;
e68dfd1972ac fix bad names.
oc
parents: 150
diff changeset
36 private int clients = 0;
98
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
37 public MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>();
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
38 private RequestScreenThread rThread;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
39 public int acceptPort = 0;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
40 private String myAddress;
94
75879c316796 synchronized wait for Rfb initialization in change server.
oc
parents: 89
diff changeset
41 protected boolean readyReconnect = false;
98
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
42 private boolean cuiVersion;
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
43 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
44 public ServerSocket servSock;
123
233e94a7b5ed add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
45 private boolean permitChangeScreen = true;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
46 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
47
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
48 private Inflater inflater = new Inflater();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
49 private Deflater deflater = new Deflater();
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
50 ViewerInterface viewer;
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
51 private short id; // my tree node id ( = 0 in root )
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
52 private boolean leader;
179
c1b91dd27a13 on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 178
diff changeset
53 public TreeManagement treeManager;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
54 private TreeVncCommandChannelListener acceptThread;
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
55 private boolean firstTime = true;
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
56 private TreeRootFinderListener getCast;
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
57 private CreateConnectionParam cp;
178
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
58 private boolean hasViewer = false;
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
59 private boolean reconnecting;
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
60 private short reconnectingId; // Change Server Request to id's node VNC server
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
61
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
62
33
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
63 public MyRfbProto() {
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
64 rThread = new RequestScreenThread(this);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
65 }
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
66
120
c1b14cef2704 MyRfb fix done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
67 abstract public boolean isRoot() ;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
68
164
86289e56263c Send initData in server change
oc
parents: 160
diff changeset
69 public ProtocolContext getContext() {
86289e56263c Send initData in server change
oc
parents: 160
diff changeset
70 return context;
86289e56263c Send initData in server change
oc
parents: 160
diff changeset
71 }
86289e56263c Send initData in server change
oc
parents: 160
diff changeset
72
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
73 /**
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
74 * handle new client accept
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
75 * it also handle TreeVNC Command
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
76 * @param acceptThread
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
77 * @param newCli
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
78 * @param os
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
79 * @param is
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
80 * @throws IOException
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
81 * @throws TransportException
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
82 */
157
7cea8789387b thread base command listening loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
83 public void newClient(final Socket newCli,final Writer os, final Reader is) {
124
214d4f206431 add TreeVNC command number.
oc
parents: 123
diff changeset
84
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
85 final int myId = clients;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
86 final MulticastQueue.Client<LinkedList<ByteBuffer>> c = multicastqueue.newClient();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
87 final AtomicInteger writerRunning = new AtomicInteger();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
88 writerRunning.set(1);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
89 /**
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
90 * Timeout thread. If a client is suspended, it has top of queue
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
91 * indefinitely, which caused memory overflow. After the timeout, we
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
92 * poll the queue and discard it. Start long wait if writer is running.
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
93 */
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
94 final Runnable timer = new Runnable() {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
95 public void run() {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
96 int count = 0;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
97 for (;;) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
98 long timeout = 50000 / 8;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
99 try {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
100 synchronized (this) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
101 int state, flag;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
102 writerRunning.set(0);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
103 wait(timeout);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
104 flag = 0;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
105 while ((state = writerRunning.get()) == 0) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
106 c.poll(); // discard, should be timeout
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
107 count++;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
108 if (flag == 0) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
109 System.out.println("Discarding " + myId
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
110 + " count=" + count);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
111 flag = 1;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
112 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
113 wait(10); // if this is too short, writer cannot
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
114 // take the poll, if this is too
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
115 // long, memory will overflow...
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
116 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
117 if (flag == 1)
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
118 System.out.println("Resuming " + myId
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
119 + " count=" + count);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
120 if (state != 1) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
121 System.out.println("Client died " + myId);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
122 break;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
123 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
124 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
125 } catch (InterruptedException e) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
126 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
127 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
128 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
129 };
88
a719aa609e14 add name valuer threads.
oc
parents: 85
diff changeset
130 new Thread(timer, "timer-discard-multicastqueue").start();
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
131 /**
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
132 * handle command from lower node
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
133 */
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
134 final Runnable reader = new Runnable() {
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
135
122
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
136 public void run() {
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
137 for (;;) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
138 try {
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
139 final byte b[] = new byte[4096];
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
140 final int c = is.readByte(b);
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
141 if (c <= 0)
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
142 throw new IOException();
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
143 if (isRoot()) {
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
144 if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) {
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
145 if (permitChangeScreen()) {
109
457f9dfbf7ce minor fix.
oc
parents: 107
diff changeset
146 ByteBuffer buf = ByteBuffer.wrap(b);
457f9dfbf7ce minor fix.
oc
parents: 107
diff changeset
147 buf.order(ByteOrder.BIG_ENDIAN);
170
2c36ea3f93da send id in initData message and changeServer.
oc
parents: 169
diff changeset
148 short id = buf.getShort(2);
109
457f9dfbf7ce minor fix.
oc
parents: 107
diff changeset
149 int length = buf.getInt(4);
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
150 if (length == 0)
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
151 continue;
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
152 String newHostName = new String(b, 8, length);
111
a7988d3c0266 minor fix.
oc
parents: 110
diff changeset
153 System.out.println("Root server change request :" + newHostName);
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
154 // please remove these numbers.
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
155 if (viewer != null) {
177
8019a393875a proxy reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
156 changeVNCServer(viewer, newHostName, 3200, 1980, id);
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
157 }
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
158 } else {
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
159 continue;
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
160 }
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
161 }
110
464eb64e3fd6 minor fix.
oc
parents: 109
diff changeset
162 } else if (b[0] == ClientToServerMessage.SERVER_CHANGE_REQUEST) {
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
163 ClientToServerMessage sc = new ClientToServerMessage() {
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
164 @Override
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
165 public void send(Writer writer)
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
166 throws TransportException {
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
167 writer.write(b,0,c);
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
168 }
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
169 };
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
170 context.sendMessage(sc);
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
171 }
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
172 // System.out.println("client read "+c);
89
1503a373ab73 close client correctly in -d mode.
oc
parents: 88
diff changeset
173 } catch (Exception e) {
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
174 try {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
175 writerRunning.set(2);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
176 os.close();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
177 is.close();
36
b7d4d0349f99 write part of reconnection and remove warning.
one
parents: 35
diff changeset
178 break;
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
179 } catch (IOException e1) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
180 } catch (TransportException e1) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
181 e1.printStackTrace();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
182 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
183 return;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
184 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
185 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
186 }
107
660b296d4f75 send change screen command throw the tree.
oc
parents: 103
diff changeset
187
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
188 };
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
189 /**
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
190 * send packets to a client (one thread for each client )
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
191 */
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
192 Runnable sender = new Runnable() {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
193 public void run() {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
194 writerRunning.set(1);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
195 try {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
196 requestThreadNotify();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
197
88
a719aa609e14 add name valuer threads.
oc
parents: 85
diff changeset
198 // after this, we discard upward packet.
131
95f53663295c lost host and parent not found
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
199 new Thread(reader, "upward-packet-processing").start();
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
200
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
201 for (;;) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
202 LinkedList<ByteBuffer> bufs = c.poll();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
203 int inputIndex = 0;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
204 ByteBuffer header = bufs.get(inputIndex);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
205 if (header == null)
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
206 continue;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
207 else if (header.get(0) == CheckDelay) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
208 writeToClient(os, bufs, inputIndex);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
209 continue;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
210 } else if (header.get(0) == FramebufferUpdate) {
63
84f1c39ba3bf temp commit
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
211 //System.out.println("client "+ myId);
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
212 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
213 /*
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
214 * if(i%20==0){ sendDataCheckDelay(); } i++;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
215 */
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
216 writeToClient(os, bufs, inputIndex);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
217 writerRunning.set(1); // yes my client is awaking.
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
218 }
89
1503a373ab73 close client correctly in -d mode.
oc
parents: 88
diff changeset
219 } catch (Exception e) {
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
220 try {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
221 writerRunning.set(2);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
222 os.close();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
223 } catch (IOException e1) {
160
b9052986bbb3 fix command loop.
oc
parents: 157
diff changeset
224 System.out.println("root writer close faild :" + e1);
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
225 }
160
b9052986bbb3 fix command loop.
oc
parents: 157
diff changeset
226 System.out.println("root writer faild :" + e);
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
227 /* if socket closed cliList.remove(newCli); */
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
228 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
229 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
230
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
231 public void writeToClient(final Writer os,
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
232 LinkedList<ByteBuffer> bufs, int inputIndex)
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
233 throws TransportException {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
234 while (inputIndex < bufs.size()) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
235 ByteBuffer b = bufs.get(inputIndex++);
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
236 os.write(b.array(), b.position(), b.limit());
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
237 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
238 os.flush();
74
f1938dd3b518 don't heap space error.
oc
parents: 69
diff changeset
239 bufs = null;
f1938dd3b518 don't heap space error.
oc
parents: 69
diff changeset
240 multicastqueue.heapAvailable();
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
241 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
242 };
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
243 clients++;
88
a719aa609e14 add name valuer threads.
oc
parents: 85
diff changeset
244 new Thread(sender, "writer-to-lower-node").start();
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
245
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
246 }
157
7cea8789387b thread base command listening loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 153
diff changeset
247
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
248
122
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
249
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
250 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
251 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
252 }
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
253
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
254
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
255 public void setPermitChangeScreen(boolean v) {
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
256 permitChangeScreen = v;
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
257 }
e2416a246c95 noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
258
88
a719aa609e14 add name valuer threads.
oc
parents: 85
diff changeset
259 public void requestThreadNotify() {
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
260 rThread.reStart();
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
261 }
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
262
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
263
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
264 public void setProtocolContext(Protocol workingProtocol) {
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
265 context = workingProtocol;
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
266 }
29
57eb5575e6c4 MyRfbProto for client and proxy.
one
parents: 28
diff changeset
267
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
268 public Socket accept() throws IOException {
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
269 return servSock.accept();
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
270 }
31
872d9bcbfe56 Before changing the Viewer.
one
parents: 29
diff changeset
271
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
272 public int selectPort(int p) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
273 int port = p;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
274 while (true) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
275 try {
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
276 servSock = new ServerSocket(port);
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
277 acceptPort = port;
181
9c02b5a72bf9 fix root myAddress.
oc
parents: 179
diff changeset
278 myAddress = "127.0.0.1";
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
279 break;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
280 } catch (BindException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
281 port++;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
282 continue;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
283 } catch (IOException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
284
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
285 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
286 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
287 System.out.println("accept port = " + port);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
288 return port;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
289 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
290
33
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
291
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
292
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
293 public void writeFramebufferUpdateRequest(int x, int y, int w, int h,
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
294 boolean incremental) throws TransportException {
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
295 byte[] b = new byte[10];
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
296
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
297 b[0] = (byte) FramebufferUpdateRequest; // 3 is FrameBufferUpdateRequest
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
298 b[1] = (byte) (incremental ? 1 : 0);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
299 b[2] = (byte) ((x >> 8) & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
300 b[3] = (byte) (x & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
301 b[4] = (byte) ((y >> 8) & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
302 b[5] = (byte) (y & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
303 b[6] = (byte) ((w >> 8) & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
304 b[7] = (byte) (w & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
305 b[8] = (byte) ((h >> 8) & 0xff);
9d3478d11d3b Add the processing of client
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
306 b[9] = (byte) (h & 0xff);
35
1b81deb0abb3 write a little part reconnection.
one
parents: 33
diff changeset
307 }
1b81deb0abb3 write a little part reconnection.
one
parents: 33
diff changeset
308
153
e68dfd1972ac fix bad names.
oc
parents: 150
diff changeset
309 public void setViewer(ViewerInterface v) {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
310 viewer = v;
36
b7d4d0349f99 write part of reconnection and remove warning.
one
parents: 35
diff changeset
311 }
b7d4d0349f99 write part of reconnection and remove warning.
one
parents: 35
diff changeset
312
153
e68dfd1972ac fix bad names.
oc
parents: 150
diff changeset
313 public ViewerInterface getViewer() {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
314 return viewer;
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
315 }
43
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
316
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
317 public void setTerminationType(boolean setType) {
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
318 /*nop*/
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
319 }
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
320
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
321 public boolean getTerminationType() {
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
322 /*nop*/
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
323 return true;
6687aa9dd55e add flag for screen change in ReciverTask.java.
one
parents: 38
diff changeset
324 }
45
20326a4b9d88 create new change button for client.
one
parents: 43
diff changeset
325
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
326 public void close() {
102
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
327 // none
52
986f16afb753 update before change host.
one
parents: 45
diff changeset
328 }
45
20326a4b9d88 create new change button for client.
one
parents: 43
diff changeset
329
60
ac6f9e46566f proxy mode ok.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
330 public int getAcceptPort() {
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
331 return acceptPort;
60
ac6f9e46566f proxy mode ok.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
332 }
ac6f9e46566f proxy mode ok.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
333
61
d9cf08c6415c During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
334 public boolean getReadyReconnect() {
d9cf08c6415c During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
335 return readyReconnect;
d9cf08c6415c During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
336 }
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
337
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
338
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
339 public boolean getCuiVersion() {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
340 return cuiVersion;
61
d9cf08c6415c During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 60
diff changeset
341 }
65
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
342
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
343 public void setCuiVersion(boolean flag) {
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
344 cuiVersion = flag;
ffd7537cebfc cuiversion
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 64
diff changeset
345 }
66
84ad879891e9 dont move
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
346
84ad879891e9 dont move
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
347 public void readCheckDelay(Reader reader) throws TransportException {
84ad879891e9 dont move
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
348
84ad879891e9 dont move
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents: 65
diff changeset
349 }
134
128cce60c43c where to connect command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
350
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
351 public synchronized void setReadyReconnect(boolean ready) {
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
352 if (reconnecting) {
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
353 sendDesktopSizeChange(reconnectingId);
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
354 reconnecting = false;
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
355 }
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
356 if (reconnectingId!=0) {
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
357 readyReconnect = ready;
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
358 if (ready) {
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
359 notifyAll();
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
360 }
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
361 }
94
75879c316796 synchronized wait for Rfb initialization in change server.
oc
parents: 89
diff changeset
362 }
75879c316796 synchronized wait for Rfb initialization in change server.
oc
parents: 89
diff changeset
363
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
364 public synchronized void waitForReady() throws InterruptedException {
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
365 if (reconnectingId!=0) {
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
366 while (!readyReconnect) {
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
367 wait();
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
368 }
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
369 }
94
75879c316796 synchronized wait for Rfb initialization in change server.
oc
parents: 89
diff changeset
370 }
96
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
371
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
372
170
2c36ea3f93da send id in initData message and changeServer.
oc
parents: 169
diff changeset
373 public void sendDesktopSizeChange(short id) {
96
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
374 LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>();
97
44f5cdc63a76 don't create Rfb and VNC proxy on change server on root.
oc
parents: 96
diff changeset
375 int width = context.getFbWidth();
44f5cdc63a76 don't create Rfb and VNC proxy on change server on root.
oc
parents: 96
diff changeset
376 int height = context.getFbHeight();
169
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
377 desktopSize.add(new UpdateRectangleMessage(width, height, EncodingType.INIT_DATA, context.getInitData(),id).getMessage());
99
da5f74092be8 minor fix.
oc
parents: 98
diff changeset
378 addSerialNumber(desktopSize);
96
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
379 multicastqueue.put(desktopSize);
76e49dd9c9c5 Client resize without reconnection
oc
parents: 94
diff changeset
380 }
98
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
381
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
382
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
383 public void addSerialNumber(LinkedList<ByteBuffer> bufs) {
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
384 ByteBuffer serialNum = multicastqueue.allocate(8);
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
385 serialNum.putLong(counter++);
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
386 serialNum.flip();
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
387 bufs.addFirst(serialNum);
8f4c45c1b396 add serial number to desktop size encoding packet.
oc
parents: 97
diff changeset
388 }
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
389
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
390
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
391 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
392 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
393 }
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
394
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
395 public void stopReceiverTask() {
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
396 if (context!=null)
1f7ee648e1f6 inflator in MyRfbProtoProxy should be renew to accept new VNC server socket.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
397 context.cleanUpSession(null);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
398 // cleanup zlib decoder for new VNCServer
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
399 if (isRoot())
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
400 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
401 }
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
402
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
403 public String getMyAddress() {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
404 return myAddress;
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
405 }
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
406
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
407 /**
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
408 * gzip byte arrays
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
409 *
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
410 * @param deflater
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
411 * @param inputs
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
412 * byte data[]
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
413 * @param inputIndex
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
414 * @param outputs
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
415 * byte data[]
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
416 * @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
417 * @throws IOException
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
418 */
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
419 public int zip(Deflater deflater, LinkedList<ByteBuffer> inputs,
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
420 int inputIndex, LinkedList<ByteBuffer> outputs) throws IOException {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
421 int len = 0;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
422 ByteBuffer c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
423 while (inputIndex < inputs.size()) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
424 ByteBuffer b1 = inputs.get(inputIndex++);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
425 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
426 /**
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
427 * 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
428 * 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
429 * 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
430 * 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
431 * of bug of Java library.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
432 */
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
433 if (inputIndex == inputs.size())
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
434 deflater.finish();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
435 int len1 = 0;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
436 do {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
437 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
438 c1.remaining());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
439 if (len1 > 0) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
440 len += len1;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
441 c1.position(c1.position() + len1);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
442 if (c1.remaining() == 0) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
443 c1.flip();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
444 outputs.addLast(c1);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
445 c1 = multicastqueue.allocate(INFLATE_BUFSIZE);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
446 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
447 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
448 } 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
449 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
450 if (c1.position() != 0) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
451 c1.flip();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
452 outputs.addLast(c1);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
453 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
454 deflater.reset();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
455 return len;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
456 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
457
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
458 /**
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
459 * gunzip byte arrays
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
460 *
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
461 * @param inflater
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
462 * @param inputs
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
463 * byte data[]
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
464 * @param bytes
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
465 * byte data[]
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
466 * @return number of total bytes
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
467 * @throws IOException
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
468 */
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
469 public int unzip(Inflater inflater, LinkedList<ByteBuffer> inputs,
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
470 int inputIndex, byte[] bytes, int bufSize)
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
471 throws DataFormatException {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
472 int position = 0;
b3426724667b fix read send data.
oc
parents: 181
diff changeset
473 int limit = bytes.length;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
474 while (inputIndex < inputs.size()) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
475 ByteBuffer input = inputs.get(inputIndex++);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
476 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
477 // 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
478 // we need this
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
479 // 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
480 do {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
481 int len0 = inflater.inflate(bytes, position,
b3426724667b fix read send data.
oc
parents: 181
diff changeset
482 limit-position);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
483 if (len0 > 0) {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
484 position += len0;
b3426724667b fix read send data.
oc
parents: 181
diff changeset
485 if (position > limit) {
b3426724667b fix read send data.
oc
parents: 181
diff changeset
486 throw new DataFormatException();
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
487 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
488 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
489 } while (!inflater.needsInput());
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
490 }
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
491 return position;
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
492 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
493
135
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
494 /**
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
495 * 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
496 * put the packet to the multicastqueue. Then normal rendering engine read the same stream using is.reset().
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
497 * @param dataLen
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
498 * @param reader
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
499 * @throws TransportException
ada4d850a820 lostParent and notFoundParenet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
500 */
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
501 public void readSendData(int dataLen, Reader reader, byte[] bytes)
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
502 throws TransportException {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
503 LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
504 ByteBuffer header = multicastqueue.allocate(16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
505 ByteBuffer serial = multicastqueue.allocate(8);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
506 if (!isRoot()) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
507 reader.readBytes(serial.array(),0,8);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
508 serial.limit(8);
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
509 }
185
feefc1e58153 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 182
diff changeset
510 reader.mark(dataLen);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
511 reader.readBytes(header.array(), 0, 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
512 header.limit(16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
513 if (header.get(0) == FramebufferUpdate) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
514 int encoding = header.getInt(12);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
515 if (encoding == EncodingType.ZRLE.getId()
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
516 || encoding == EncodingType.ZLIB.getId()) {
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
517 // recompress into ZREE
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
518 // 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
519 ByteBuffer len = multicastqueue.allocate(4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
520 reader.readBytes(len.array(), 0, 4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
521 len.limit(4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
522 ByteBuffer inputData = multicastqueue.allocate(dataLen - 20);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
523 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
524 inputData.limit(dataLen - 20);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
525 LinkedList<ByteBuffer> inputs = new LinkedList<ByteBuffer>();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
526 inputs.add(inputData);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
527
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
528 header.putInt(12, EncodingType.ZRLEE.getId()); // means
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
529 // recompress
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
530 // every time
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
531 // 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
532 // protocol, clients have to be modified.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
533 Deflater nDeflater = deflater; // new Deflater();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
534 LinkedList<ByteBuffer> out = new LinkedList<ByteBuffer>();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
535 try {
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
536 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
537 // dump32(inputs);
182
b3426724667b fix read send data.
oc
parents: 181
diff changeset
538 out.add(ByteBuffer.wrap(bytes));
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
539 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
540 ByteBuffer blen = multicastqueue.allocate(4);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
541 blen.putInt(len2);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
542 blen.flip();
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
543 bufs.addFirst(blen);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
544 bufs.addFirst(header);
146
5be1d92e7835 not working yet
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
545 addSerialNumber(bufs);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
546 multicastqueue.put(bufs);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
547 } catch (DataFormatException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
548 throw new TransportException(e);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
549 } catch (IOException e) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
550 throw new TransportException(e);
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 return;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
553 }
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
554 // ZRLEE is already compressed
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
555 bufs.add(header);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
556 if (dataLen > 16) {
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
557 ByteBuffer b = multicastqueue.allocate(dataLen - 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
558 reader.readBytes(b.array(), 0, dataLen - 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
559 b.limit(dataLen - 16);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
560 bufs.add(b);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
561 }
120
c1b14cef2704 MyRfb fix done.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
562 this.addSerialNumber(bufs);
118
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
563 multicastqueue.put(bufs);
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
564 return;
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
565 }
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
566 // It may be compressed. We can inflate here to avoid repeating clients
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
567 // decompressing here,
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
568 // but it may generate too many large data. It is better to do it in
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
569 // each client.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
570 // But we have do inflation for all input data, so we have to do it
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
571 // here.
38e461e9b9c9 remove duplicated code in MyRfbProto*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 113
diff changeset
572 }
124
214d4f206431 add TreeVNC command number.
oc
parents: 123
diff changeset
573
145
649794dfb9d5 add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
574 public abstract void addHostToSelectionPanel(int port, String hostname,String myHostName) ;
143
4547543ca73c findRootReply
oc
parents: 138
diff changeset
575
144
1e004d9c599d notify connection panel
oc
parents: 143
diff changeset
576 public void createRootSelectionPanel(CreateConnectionParam createConnectionParam) {
143
4547543ca73c findRootReply
oc
parents: 138
diff changeset
577
4547543ca73c findRootReply
oc
parents: 138
diff changeset
578 }
4547543ca73c findRootReply
oc
parents: 138
diff changeset
579
169
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
580 public void setId(short id) {
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
581 this.id = id;
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
582 }
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
583
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
584 public short getId() {
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
585 return id;
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
586 }
8ab1f6905db4 Try to hide root frame
oc
parents: 166
diff changeset
587
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
588 public void setMyAddress(String myHostName) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
589 this.myAddress = myHostName;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
590
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
591 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
592
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
593 public void setLeader(boolean leader) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
594 this.leader = leader;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
595 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
596
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
597 public boolean isLeader() {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
598 return leader;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
599 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
600
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
601 public void setTreeManager(TreeManagement clients) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
602 treeManager = clients;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
603 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
604
188
f176bffcdc4a add showTreeNode option.
oc
parents: 187
diff changeset
605 public TreeManagement getTreeManager() {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
606 return treeManager;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
607 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
608
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
609 /**
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
610 * chnageVNCServer is called when host change.
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
611 *
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
612 * @param vncProxyService
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
613 * @param hostName
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
614 * HostAddress
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
615 * @param width
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
616 * FrameWidth
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
617 * @param height
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
618 * FrameHeight
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
619 * @param id
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
620 * @throws InterruptedException
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
621 */
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
622 public void changeVNCServer(ViewerInterface vncProxyService, String hostName, int width, int height, short id)
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
623 throws UnknownHostException, IOException, InterruptedException {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
624 // stop reader stop
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
625 stopReceiverTask();
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
626 vncProxyService.inhelitClients(vncProxyService, hostName);
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
627 // after connecting VNC server, rfb send SEND_INIT_DATA command and wakes me up if necessary
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
628 reconnecting = true;
187
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
629 if (reconnectingId!=0) {
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
630 waitForReady();
b62a16548800 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 186
diff changeset
631 }
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
632 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
633
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
634 /**
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
635 * start accepting children
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
636 * run rootFinderListener if necessary
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
637 */
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
638 public void createConnectionAndStart(ViewerInterface v) {
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
639 selectPort(ConnectionParams.DEFAULT_VNC_ROOT);
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
640 if (treeManager!=null) {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
641 treeManager.getList().getFirst().setPort(getAcceptPort());
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
642 }
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
643 startTreeVncCommandListener();
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
644 if(isRoot() && firstTime) {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
645 getCast = new TreeRootFinderListener(v);
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
646 Thread thread = new Thread(getCast, "tree-root-find-listener");
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
647 thread.start();
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
648 firstTime = false;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
649 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
650 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
651
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
652 public void startTreeVncCommandListener() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
653 acceptThread = new TreeVncCommandChannelListener(this, getAcceptPort());
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
654 Thread thread = new Thread(acceptThread, "TreeVNC-accept");
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
655 thread.start();
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
656 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
657
174
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
658 public TreeVncCommandChannelListener getAcceptThread() {
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
659 return acceptThread;
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
660 }
2e1530139169 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
661
176
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
662 public void setConnectionParam(CreateConnectionParam createConnectionParam) {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
663 cp = createConnectionParam;
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
664 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
665
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
666 public CreateConnectionParam getConnectionParam() {
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
667 return cp;
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
668 }
fa6cfb85444e on going ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
669
178
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
670 public boolean hasViewer() {
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
671 return hasViewer;
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
672 }
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
673
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
674 public void setHasViewer(boolean b) {
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
675 hasViewer = b;
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
676 }
34b7558aeffa remove TreeTask, StartTreeHandling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 177
diff changeset
677
186
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
678 public void setReconnecting(boolean b) {
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
679 reconnecting = b;
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
680 }
f76ee760c2d2 dead lock on command line root
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 185
diff changeset
681
164
86289e56263c Send initData in server change
oc
parents: 160
diff changeset
682
28
18fad65bc447 Create MyRfbProto.java
one
parents:
diff changeset
683 }