view src/main/java/jp/ac/u_ryukyu/treevnc/ScreenChangeRequest.java @ 427:ed15f0bd8dfa

Remove shareScrrenNumber for ScreenChangeRequest Message
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Mon, 01 Feb 2016 04:39:53 +0900
parents c225c7963778
children
line wrap: on
line source

package jp.ac.u_ryukyu.treevnc;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import com.glavsoft.exceptions.TransportException;
import com.glavsoft.rfb.client.ClientToServerMessage;
import com.glavsoft.transport.Writer;

	/**
	 * ServerChangeRequest
     * Change VNCServer
	 * 1      - U8       - 240
	 * 3      -          - padding
     * 4      -          - id
	 * 4      - U32      - length
	 * length - U8 array - text
	 */
	public class ScreenChangeRequest implements ClientToServerMessage {
		final String bytes;
        private final int scale;
        private final int x;
        private final int y;
        private short id;
        private int frameSizeWidth;
        private int frameSizeHeight;
        private int port;

        public ScreenChangeRequest(String adr, int port, short id, int x, int y, int width, int height, int scale) {
			this.bytes = adr;
            this.port = port;
			this.id = id;
            this.x = x;
            this.y = y;
            this.frameSizeWidth = width;
            this.frameSizeHeight = height;
            this.scale = scale;
			System.out.println("Client send change screen server request :" + adr);
		}

        @Override
        public void send(Writer writer) throws TransportException {
            ByteBuffer out = ByteBuffer.allocate(bytes.length()+37);
            out.order(ByteOrder.BIG_ENDIAN);
            out.put(SERVER_CHANGE_REQUEST);
            out.put((byte)0); // padding
            out.putShort(id);
            out.putInt(bytes.length());
            out.put(bytes.getBytes());
            out.putInt(x);
            out.putInt(y);
            out.putInt(frameSizeWidth);
            out.putInt(frameSizeHeight);
            out.putInt(port);
            out.putInt(scale);
            writer.write(out.array(), 0, out.position());
            writer.flush();
        }

		@Override
		public String toString() {
			return "Screen change request: [length: " + bytes.length() +", text: ...]" + new String (bytes) + " : " + port;
		}
	}