Mercurial > hg > Applications > TightVNC_orginal
view src/main/java/ac/ryukyu/treevnc/client/MyRfbProtoClient.java @ 3:e7ce2b2ffed8
add and modify files
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Jul 2012 15:46:36 +0900 |
parents | |
children | b32668b8e83c |
line wrap: on
line source
package ac.ryukyu.treevnc.client; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.nio.ByteBuffer; import com.glavsoft.exceptions.TransportException; import com.glavsoft.transport.Reader; import com.glavsoft.viewer.ContainerManager; import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams; public class MyRfbProtoClient { private Reader reader; private EchoClient echoValue = new EchoClient(); private String host,treenum,parent,pHost,leaderflag; private int echoPort,port; Socket clientSocket,sock; DataInputStream is; OutputStream os; private ContainerManager containerManager; public MyRfbProtoClient(Reader reader,String host,String port) { this.reader = reader; } public void setParam(ConnectionParams connectionParams) { pHost = connectionParams.hostName; echoPort = connectionParams.portNumber; } public boolean readProxyFlag() throws TransportException { int flag = reader.readUInt8(); if(flag == 1) return true; else return false; } public byte[] readEchoPort() throws Exception { byte[] b = new byte[4]; reader.readBytes(b, 0, b.length); //readFully(b); return b; } public void getParentName() { if (echoValue == null) { if (clientSocket == null) { // echo = new EchoClient(pHost, this); echoValue = new EchoClient(pHost, echoPort); echoValue.openport(); echoValue = echoValue.requestHostName("1"); } else { echoValue = new EchoClient(); echoValue = echoValue.Interruption(clientSocket); } } // proxyからの返信で接続先を決定する host = echoValue.responseLine; parent = echoValue.parent; if (echoValue.treenum != null) { treenum = echoValue.treenum; } else { treenum = echoValue.treenum; } if (echoValue.leaderflag != null) { leaderflag = echoValue.leaderflag; } else { leaderflag = echoValue.leaderflag; } } int castByteInt(byte[] b) { ByteBuffer bb = ByteBuffer.wrap(b); int value = bb.getInt(); return value; } Socket changeParent(String host, int port) throws IOException { sock = new Socket(host, port); return sock; } }