view src/main/java/jp/ac/u_ryukyu/treevnc/SendCheckDelay.java @ 241:b21a7842a41d

add option addSerialNum.
author oc
date Mon, 13 Oct 2014 13:16:49 +0900
parents 7310e7d7a45f
children a640cd7001e1
line wrap: on
line source

package jp.ac.u_ryukyu.treevnc;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.LinkedList;

import com.glavsoft.rfb.encoding.EncodingType;


public class SendCheckDelay implements Runnable {
    
    private TreeRFBProto rfb;
    
    public SendCheckDelay(TreeRFBProto rfb) {
        this.rfb = rfb;
    }
    
    public void sendCheckDelay() throws UnsupportedEncodingException {
        
        LinkedList<ByteBuffer> checkdelay = new LinkedList<ByteBuffer>();
        long time = System.currentTimeMillis();
        checkdelay.add(new CheckDelay(0, 0, 0, 0, time, EncodingType.CHECK_DELAY).getMessage());
        if (rfb.addSerialNum) {
            rfb.addSerialNumber(checkdelay);
        }
        rfb.multicastqueue.put(checkdelay);
    }
    
    public void run() {
        for (;;) {
            long timeout = 50000 / 8;
            try {
                synchronized (this) {
                    wait(timeout);
                    sendCheckDelay();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    }

}