view src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java @ 145:649794dfb9d5

add my hostname to handle multiple network
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 12 Jun 2014 22:01:05 +0900
parents f35479f25f4a
children e68dfd1972ac
line wrap: on
line source

package jp.ac.u_ryukyu.treevnc.server;

//import static org.junit.Assert.*;
//import org.junit.Test;

import java.io.IOException;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.util.LinkedList;

import com.glavsoft.transport.Writer;

import java.util.concurrent.ExecutorService;

import jp.ac.u_ryukyu.treevnc.MyRfbProto;

public class MyRfbProtoProxy extends MyRfbProto {
	/**
	 * CheckMillis is one of new msgType for RFB 3.855 and 3.856.
	 */
	final static byte SpeedCheckMillis = 4;

	// Secyrity type of OS X
	final static int SecTypeReqAccess = 32;

	// Supported authentication types
	final static int AuthAccess = 32;

	boolean printStatusFlag = false;
	long startCheckTime;

	private LinkedList<Socket> cliListTmp;
	private LinkedList<Socket> cliList;
	boolean createBimgFlag;
	boolean proxyFlag = true;
	ExecutorService executor;

	byte[] pngBytes;

	public RequestScreenThread rThread;
	private Thread requestThread;
	
	public MyRfbProtoProxy() {
		rThread = new RequestScreenThread(this);
		requestThread = new Thread(rThread);
	}

	@Override
    public boolean isRoot() {
        return true;
    }
    
	public void setStream(Writer _writer) {
		// os = _writer;
	}

	public int getAcceptPort() {
		return acceptPort;
	}

	void setSoTimeout(int num) throws IOException {
		servSock.setSoTimeout(num);
	}

	public Socket accept() throws IOException {
		return servSock.accept();
	}

	public void socketClose() throws IOException {
		servSock.close();
	}

	void addSock(Socket sock) {
		cliList.add(sock);
	}

	void addSockTmp(Socket sock) {
		System.out.println("connected " + sock.getInetAddress());
		cliListTmp.add(sock);
	}

	void requestThreadStart() {
		requestThread.start();
	}

	public synchronized void requestThreadNotify() {
		rThread.reStart();
	}

	public void dump32(LinkedList<ByteBuffer> bufs) {
		int len = 0;
		for (ByteBuffer b : bufs)
			len += b.remaining();
		ByteBuffer top = bufs.getFirst();
		ByteBuffer end = bufs.getLast();
		System.err.println("length: " + len);
		System.err.print("head 0: ");
		for (int i = 0; i < 16 && i < top.remaining(); i++) {
			System.err.print(" " + top.get(i));
		}
		System.err.print("tail 0: ");
		for (int i = 0; i < 16 && i < end.remaining(); i++) {
			System.err.print(" " + end.get(i));
		}
		System.err.println();
	}



	@Override
	public boolean getReadyReconnect() {
		return readyReconnect;
	}
	

	
    @Override
    public void addHostToSelectionPanel(int port, String hostname,
            String myHostName) {
    }


}