Mercurial > hg > Applications > TreeVNC
annotate src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java @ 113:bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 May 2014 23:52:21 +0900 |
parents | 918dc3ee1c79 |
children | 2c36ea3f93da |
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; |
107 | 23 |
112 | 24 public ScreenChangeRequest(String adr) { |
25 this.bytes = adr; | |
26 System.out.println("Client send change screen server request :" + adr); | |
107 | 27 } |
28 | |
29 @Override | |
30 public void send(Writer writer) throws TransportException { | |
112 | 31 ByteBuffer out = ByteBuffer.allocate(bytes.length()+16); |
32 out.order(ByteOrder.BIG_ENDIAN); | |
33 out.put(SERVER_CHANGE_REQUEST); | |
34 out.put((byte)0); | |
35 out.putShort((byte)0); // padding | |
36 out.putInt(bytes.length()); | |
37 out.put(bytes.getBytes()); | |
38 writer.write(out.array(), 0, out.position()); | |
107 | 39 writer.flush(); |
112 | 40 } |
107 | 41 |
42 @Override | |
43 public String toString() { | |
112 | 44 return "Screen change request: [length: " + bytes.length() +", text: ...]" + new String (bytes); |
107 | 45 } |
46 } |