annotate src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java @ 112:918dc3ee1c79

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