annotate src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java @ 257:11b59b223222

add function of fixing display size
author oc
date Mon, 01 Dec 2014 17:03:27 +0900
parents 2c36ea3f93da
children 9c5874d0f37e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
1 package jp.ac.u_ryukyu.treevnc;
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
2
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
3 import java.nio.ByteBuffer;
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
4 import java.nio.ByteOrder;
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
5
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
6 import com.glavsoft.exceptions.TransportException;
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
7 import com.glavsoft.rfb.client.ClientToServerMessage;
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
8 import com.glavsoft.transport.Writer;
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
9
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
10 /**
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
11 * ClientCutText
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
12 * The client has new ISO 8859-1 (Latin-1) text in its cut buffer. Ends of lines are repre-
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
13 * sented by the linefeed / newline character (value 10) alone. No carriage-return (value
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
14 * 13) is needed. There is currently no way to transfer text outside the Latin-1 character
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
15 * set.
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
16 * 1 - U8 - 6
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
17 * 3 - - padding
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
18 * 4 - U32 - length
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
19 * length - U8 array - text
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
20 */
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
21 public class ScreenChangeRequest implements ClientToServerMessage {
113
bce2ef0a2e79 use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
22 final String bytes;
170
2c36ea3f93da send id in initData message and changeServer.
oc
parents: 113
diff changeset
23 private short id;
257
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
24 private int frameSizeWidth;
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
25 private int frameSizeHeight;
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
26
257
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
27 public ScreenChangeRequest(String adr, short id, int width, int height) {
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
28 this.bytes = adr;
170
2c36ea3f93da send id in initData message and changeServer.
oc
parents: 113
diff changeset
29 this.id = id;
257
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
30 this.frameSizeWidth = width;
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
31 this.frameSizeHeight = height;
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
32 System.out.println("Client send change screen server request :" + adr);
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
33 }
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
34
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
35 @Override
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
36 public void send(Writer writer) throws TransportException {
257
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
37 ByteBuffer out = ByteBuffer.allocate(bytes.length()+25);
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
38 out.order(ByteOrder.BIG_ENDIAN);
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
39 out.put(SERVER_CHANGE_REQUEST);
257
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
40 out.put((byte)0); // padding
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
41 out.putShort(id);
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
42 out.putInt(bytes.length());
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
43 out.put(bytes.getBytes());
257
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
44 out.putInt(frameSizeWidth);
11b59b223222 add function of fixing display size
oc
parents: 170
diff changeset
45 out.putInt(frameSizeHeight);
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
46 writer.write(out.array(), 0, out.position());
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
47 writer.flush();
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
48 }
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
49
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
50 @Override
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
51 public String toString() {
112
918dc3ee1c79 send composed data.
oc
parents: 111
diff changeset
52 return "Screen change request: [length: " + bytes.length() +", text: ...]" + new String (bytes);
107
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
53 }
660b296d4f75 send change screen command throw the tree.
oc
parents:
diff changeset
54 }