view src/main/java/jp/ac/u_ryukyu/treevnc/SendSingleDisplayWidth.java @ 281:16d3584ae7a0

fix SEND_SINGLE_DISPLAY_WIDTH
author oc
date Sun, 11 Jan 2015 03:55:03 +0900
parents dce00f9ac98c
children c10e0dee7bbb
line wrap: on
line source

package jp.ac.u_ryukyu.treevnc;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.LinkedList;
import com.glavsoft.rfb.encoding.EncodingType;

/**
 * Created by OcBookPro on 15/01/10.
 */
public class SendSingleDisplayWidth {

    private ByteBuffer msg;
    private TreeRFBProto rfb;
    private int singleDisplayWidth;

    public SendSingleDisplayWidth(TreeRFBProto rfb, int singleWidth) {
        this.rfb = rfb;
        this.singleDisplayWidth = singleWidth;
    }

    public SendSingleDisplayWidth() {
    }

    public void sendSingleDisplayWidth() throws UnsupportedEncodingException {
        LinkedList<ByteBuffer> linkedListSendSingleDisplayWidth = new LinkedList<ByteBuffer>();
        linkedListSendSingleDisplayWidth.add(singleDisplayWidth(0, 0, this.singleDisplayWidth, 0));
        this.rfb.addSerialNumber(linkedListSendSingleDisplayWidth);
        this.rfb.multicastqueue.put(linkedListSendSingleDisplayWidth);
        System.out.println(this.singleDisplayWidth + " : send single display width");
    }

    public ByteBuffer singleDisplayWidth(int i, int j, int singleDisplayWidth, int height) throws UnsupportedEncodingException {
        msg = ByteBuffer.allocate(24).order(ByteOrder.BIG_ENDIAN);
        msg.put((byte) 0); // FrameBufferUpdate
        msg.put((byte) 0); // padding
        msg.putShort((short) 1); // number of rectangle
        msg.putShort((short) i);
        msg.putShort((short) j);
        msg.putShort((short) singleDisplayWidth);
        msg.putShort((short) height);
        msg.putInt(EncodingType.SEND_SINGLE_DISPLAY_WIDTH.getId());
        msg.flip();
        return msg;
    }

}