Mercurial > hg > Members > nobuyasu > tightVNCClient
diff src/myVncClient/MyVncClient.java @ 73:83acdeca0539
modify EchoClient
author | e085711 |
---|---|
date | Tue, 30 Aug 2011 06:59:57 +0900 |
parents | ec66d1d4dca0 |
children | 7d25b08f5835 |
line wrap: on
line diff
--- a/src/myVncClient/MyVncClient.java Mon Aug 29 03:14:53 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Tue Aug 30 06:59:57 2011 +0900 @@ -6,6 +6,8 @@ import java.net.*; import java.util.Random; +import java.nio.ByteBuffer; + public class MyVncClient extends VncViewer implements InterfaceForViewer, java.lang.Runnable, WindowListener { @@ -38,6 +40,9 @@ inAnApplet = false; inSeparateFrame = true; + host = mainArgs[0]; + port = Integer.parseInt(mainArgs[1]); + init(null); start_threads(); start(); @@ -49,8 +54,7 @@ public void init(EchoClient value) { -// getParentname(value); - readParameters(value); + readParameters(); // readParameters(); refApplet = this; @@ -351,9 +355,6 @@ showConnectionStatus("Connecting to " + host + ", port " + port + "..."); - host = "localhost"; - port = 5999; - rfb = new MyRfbProto(host, port, this); showConnectionStatus("Connected to server"); @@ -361,9 +362,16 @@ showConnectionStatus("RFB server supports protocol version " + rfb.serverMajor + "." + rfb.serverMinor); + rfb.writeVersionMsg(); + showConnectionStatus("Using RFB protocol version " + rfb.clientMajor + + "." + rfb.clientMinor); + if(rfb.serverMinor == 998) { + byte[] b = new byte[4]; + b = rfb.readEchoPort(); + int echoPort = castByteInt(b); String h = host; - getParentname(echovalue); + getParentname(echovalue, echoPort); if(h.equals(host)) { rfb.changeParent(host, port); rfb.readVersionMsg(); @@ -371,10 +379,6 @@ } - rfb.writeVersionMsg(); - showConnectionStatus("Using RFB protocol version " + rfb.clientMajor - + "." + rfb.clientMinor); - int secType = rfb.negotiateSecurity(); int authType; if (secType == RfbProto.SecTypeTight) { @@ -526,7 +530,6 @@ authPanel.moveFocusToDefaultField(); String pw = authPanel.getPassword(); vncContainer.remove(authPanel); - return pw; } @@ -776,7 +779,7 @@ * those expected in the html applet tag source. */ - void readParameters(EchoClient value) { + void readParameters() { /* * host = readParameter("HOST", !inAnApplet); * @@ -1101,7 +1104,7 @@ public void windowDeiconified(WindowEvent evt) { } - void getParentname(EchoClient value) { + void getParentname(EchoClient value, int echoPort) { if (value == null) { if (clientSocket == null) { @@ -1110,7 +1113,8 @@ pHost = mainArgs[0]; else pHost = "cls080.ie.u-ryukyu.ac.jp"; - echo = new EchoClient(pHost, this); +// echo = new EchoClient(pHost, this); + echo = new EchoClient(pHost, this, echoPort); echo.openport(); value = echo.hostn("1"); @@ -1145,11 +1149,18 @@ fatalError("HOST parameter not specified"); } } - port = 5999; - +// port = 5999; - } + } + int castByteInt(byte[] b) { + ByteBuffer bb = ByteBuffer.wrap(b); + int value = bb.getInt(); + return value; + } + + + public static void main(Socket _clientSocket) { MyVncClient v = new MyVncClient(); // v.clientSocket = _clientSocket;