view src/main/java/jp/ac/u_ryukyu/treevnc/SendCheckDelay.java @ 242:a640cd7001e1

fix checkdelay, and fix serial number option
author oc
date Mon, 13 Oct 2014 17:23:57 +0900
parents b21a7842a41d
children 8cc07511b1d5
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());
        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();
            }
        }
    }

}