Mercurial > hg > Applications > TreeVNC
view src/viewer_swing/java/com/glavsoft/viewer/TreeConnectionManager.java @ 47:f3b775d3592a
create newVps.
author | one |
---|---|
date | Thu, 06 Dec 2012 17:51:29 +0900 |
parents | 20326a4b9d88 |
children | 6ebe870da138 |
line wrap: on
line source
package com.glavsoft.viewer; import java.awt.event.WindowListener; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import jp.ac.u_ryukyu.treevnc.MyRfbProto; import jp.ac.u_ryukyu.treevnc.client.GetDataClient; import jp.ac.u_ryukyu.treevnc.client.GetHostClient; import jp.ac.u_ryukyu.treevnc.client.EchoClient; import com.glavsoft.rfb.protocol.ProtocolSettings; import com.glavsoft.viewer.swing.ParametersHandler; public class TreeConnectionManager extends ConnectionManager { /** * */ private static final long serialVersionUID = 1L; public TreeConnectionManager(WindowListener appWindowListener, boolean isApplet) { super(appWindowListener, isApplet); } @Override public Socket connectToHost(final ParametersHandler.ConnectionParams connectionParams, ProtocolSettings settings, MyRfbProto rfb) { Socket socket = null; GetHostClient bCast = new GetHostClient("who"); bCast.getHost(); GetDataClient getBcast = new GetDataClient(); Thread runBcast = new Thread(getBcast); runBcast.start(); connectionParams.hostName = getBcast.textAddress(); getBcast.interrupt(); if("notFound".equals(connectionParams.hostName)) { // connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); connectionParams.portNumber = 5900; } else { // getBcast.ipRegister(); EchoClient echo = new EchoClient(getBcast.textAddress(),9999); rfb.setEcho(echo); rfb.setProxyAddr(getBcast.textAddress()); echo.getParentName(); connectionParams.hostName = echo.parentAddress; connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); // I should get port number // connectionParams.hostName = getBcast.textAddress(); // connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); // connectionParams.portNumber = 5900; } Viewer.logger.info("Connecting to host " + connectionParams.hostName + ":" + connectionParams.portNumber); try { socket = new Socket(connectionParams.hostName, connectionParams.portNumber); socket.setReuseAddress(true); } catch (UnknownHostException e) { Viewer.logger.severe("Unknown host: " + connectionParams.hostName); showConnectionErrorDialog("Unknown host: '" + connectionParams.hostName + "'"); } catch (IOException e) { Viewer.logger.severe("Couldn't connect to: " + connectionParams.hostName + ":" + connectionParams.portNumber + ": " + e.getMessage()); showConnectionErrorDialog("Couldn't connect to: '" + connectionParams.hostName + "'\n" + e.getMessage()); } return socket; } }