Mercurial > hg > Applications > TreeVNC
annotate src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java @ 170:2c36ea3f93da
send id in initData message and changeServer.
author | oc |
---|---|
date | Fri, 20 Jun 2014 18:04:23 +0900 |
parents | bce2ef0a2e79 |
children | 11b59b223222 |
rev | line source |
---|---|
107 | 1 package jp.ac.u_ryukyu.treevnc; |
2 | |
112 | 3 import java.nio.ByteBuffer; |
4 import java.nio.ByteOrder; | |
5 | |
107 | 6 import com.glavsoft.exceptions.TransportException; |
7 import com.glavsoft.rfb.client.ClientToServerMessage; | |
8 import com.glavsoft.transport.Writer; | |
9 | |
10 /** | |
11 * ClientCutText | |
12 * The client has new ISO 8859-1 (Latin-1) text in its cut buffer. Ends of lines are repre- | |
13 * sented by the linefeed / newline character (value 10) alone. No carriage-return (value | |
14 * 13) is needed. There is currently no way to transfer text outside the Latin-1 character | |
15 * set. | |
16 * 1 - U8 - 6 | |
17 * 3 - - padding | |
18 * 4 - U32 - length | |
19 * length - U8 array - text | |
20 */ | |
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 | 23 private short id; |
107 | 24 |
170 | 25 public ScreenChangeRequest(String adr, short id) { |
112 | 26 this.bytes = adr; |
170 | 27 this.id = id; |
112 | 28 System.out.println("Client send change screen server request :" + adr); |
107 | 29 } |
30 | |
31 @Override | |
32 public void send(Writer writer) throws TransportException { | |
112 | 33 ByteBuffer out = ByteBuffer.allocate(bytes.length()+16); |
34 out.order(ByteOrder.BIG_ENDIAN); | |
35 out.put(SERVER_CHANGE_REQUEST); | |
36 out.put((byte)0); | |
170 | 37 out.putShort(id); // padding |
112 | 38 out.putInt(bytes.length()); |
39 out.put(bytes.getBytes()); | |
40 writer.write(out.array(), 0, out.position()); | |
107 | 41 writer.flush(); |
112 | 42 } |
107 | 43 |
44 @Override | |
45 public String toString() { | |
112 | 46 return "Screen change request: [length: " + bytes.length() +", text: ...]" + new String (bytes); |
107 | 47 } |
48 } |