view src/main/java/jp/ac/u_ryukyu/treevnc/CheckDelayReply.java @ 542:9ed3bfbf81de deployApp tip

make branch
author e165729 <e165729@ie.u-ryukyu.ac.jp>
date Sun, 13 Oct 2019 16:03:36 +0900
parents 3af5f4af2d63
children
line wrap: on
line source

package jp.ac.u_ryukyu.treevnc;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

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

public class CheckDelayReply implements ClientToServerMessage {

    private long time;
    private int port;
    private int addressLength;
    private int dataLen;
    private byte[] byteaddress;
    
    public CheckDelayReply(long time, int port, String address, int dataLen) throws UnsupportedEncodingException {
        this.time = time;
        this.port = port;
        this.addressLength = address.length();
        this.dataLen = dataLen;
        this.byteaddress = address.getBytes("UTF-8");
    }
    
    
    @Override
    public void send(Writer writer) throws TransportException {
        ByteBuffer out = ByteBuffer.allocate(22 + addressLength);
        out.order(ByteOrder.BIG_ENDIAN);
        out.put(CHECK_DELAY_REPLY);
        out.put((byte)0);   // padding
        out.putLong(time);
        out.putInt(port);
        out.putInt(addressLength);
        out.putInt(dataLen);
        out.put(byteaddress);
        writer.write(out.array(), 0, out.position());
        writer.flush();
    }

}