comparison 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
comparison
equal deleted inserted replaced
2:dca3bd61b830 3:e7ce2b2ffed8
1 package ac.ryukyu.treevnc.client;
2
3 import java.io.BufferedInputStream;
4 import java.io.DataInputStream;
5 import java.io.DataOutputStream;
6 import java.io.IOException;
7 import java.io.InputStream;
8 import java.io.OutputStream;
9 import java.net.InetAddress;
10 import java.net.Socket;
11 import java.nio.ByteBuffer;
12
13
14
15 import com.glavsoft.exceptions.TransportException;
16 import com.glavsoft.transport.Reader;
17 import com.glavsoft.viewer.ContainerManager;
18 import com.glavsoft.viewer.swing.ParametersHandler.ConnectionParams;
19
20 public class MyRfbProtoClient {
21 private Reader reader;
22 private EchoClient echoValue = new EchoClient();
23 private String host,treenum,parent,pHost,leaderflag;
24 private int echoPort,port;
25 Socket clientSocket,sock;
26 DataInputStream is;
27 OutputStream os;
28 private ContainerManager containerManager;
29
30
31
32 public MyRfbProtoClient(Reader reader,String host,String port) {
33 this.reader = reader;
34 }
35
36 public void setParam(ConnectionParams connectionParams) {
37 pHost = connectionParams.hostName;
38 echoPort = connectionParams.portNumber;
39 }
40
41 public boolean readProxyFlag() throws TransportException {
42 int flag = reader.readUInt8();
43 if(flag == 1)
44 return true;
45 else
46 return false;
47 }
48
49 public byte[] readEchoPort() throws Exception {
50 byte[] b = new byte[4];
51 reader.readBytes(b, 0, b.length);
52 //readFully(b);
53 return b;
54 }
55
56 public void getParentName() {
57 if (echoValue == null) {
58
59 if (clientSocket == null) {
60
61 // echo = new EchoClient(pHost, this);
62 echoValue = new EchoClient(pHost, echoPort);
63 echoValue.openport();
64
65 echoValue = echoValue.requestHostName("1");
66 } else {
67 echoValue = new EchoClient();
68 echoValue = echoValue.Interruption(clientSocket);
69 }
70 }
71 // proxyからの返信で接続先を決定する
72 host = echoValue.responseLine;
73 parent = echoValue.parent;
74 if (echoValue.treenum != null) {
75 treenum = echoValue.treenum;
76 } else {
77 treenum = echoValue.treenum;
78 }
79
80 if (echoValue.leaderflag != null) {
81 leaderflag = echoValue.leaderflag;
82 } else {
83 leaderflag = echoValue.leaderflag;
84 }
85 }
86
87 int castByteInt(byte[] b) {
88 ByteBuffer bb = ByteBuffer.wrap(b);
89 int value = bb.getInt();
90 return value;
91 }
92
93 Socket changeParent(String host, int port) throws IOException {
94 sock = new Socket(host, port);
95 return sock;
96 }
97
98 }