Mercurial > hg > Applications > TreeVNC
comparison src/viewer_swing/java/com/glavsoft/viewer/TreeConnectionManager.java @ 11:57ae9fbb1245
add files
author | Taninari YU <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Aug 2012 14:02:05 +0900 |
parents | |
children | 12c3a73be47f |
comparison
equal
deleted
inserted
replaced
10:73abb3b86ce7 | 11:57ae9fbb1245 |
---|---|
1 package com.glavsoft.viewer; | |
2 | |
3 import java.awt.event.WindowListener; | |
4 import java.io.IOException; | |
5 import java.net.Socket; | |
6 import java.net.UnknownHostException; | |
7 | |
8 import ac.ryukyu.treevnc.client.GetDataClient; | |
9 import ac.ryukyu.treevnc.client.GetHostClient; | |
10 | |
11 import com.glavsoft.rfb.protocol.ProtocolSettings; | |
12 import com.glavsoft.viewer.swing.ParametersHandler; | |
13 | |
14 public class TreeConnectionManager extends ConnectionManager { | |
15 | |
16 /** | |
17 * | |
18 */ | |
19 private static final long serialVersionUID = 1L; | |
20 public TreeConnectionManager(WindowListener appWindowListener, | |
21 boolean isApplet) { | |
22 super(appWindowListener, isApplet); | |
23 } | |
24 | |
25 @Override | |
26 public Socket connectToHost(final ParametersHandler.ConnectionParams connectionParams, ProtocolSettings settings) { | |
27 Socket socket = null; | |
28 boolean wasError = false; | |
29 GetHostClient bCast = new GetHostClient("who"); | |
30 bCast.createSocket(); | |
31 bCast.sendData(); | |
32 GetDataClient getBcast = new GetDataClient(); | |
33 Thread runBcast = new Thread(getBcast); | |
34 runBcast.start(); | |
35 getBcast.setStopFlag(true); | |
36 //connectionParams.hostName = getBcast.textAddress(); | |
37 if("notFound".equals(connectionParams.hostName)) { | |
38 getBcast.text.ipRegister(); | |
39 connectionParams.hostName = getBcast.textAddress(); | |
40 connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); | |
41 //connectionParams.portNumber = 5900; | |
42 } else { | |
43 // connectionParams.portNumber = Integer.parseInt(getBcast.textPort()); | |
44 connectionParams.portNumber = 5900; | |
45 } | |
46 Viewer.logger.info("Connecting to host " + connectionParams.hostName + ":" + connectionParams.portNumber); | |
47 try { | |
48 socket = new Socket(connectionParams.hostName, connectionParams.portNumber); | |
49 wasError = false; | |
50 } catch (UnknownHostException e) { | |
51 Viewer.logger.severe("Unknown host: " + connectionParams.hostName); | |
52 showConnectionErrorDialog("Unknown host: '" + connectionParams.hostName + "'"); | |
53 wasError = true; | |
54 } catch (IOException e) { | |
55 Viewer.logger.severe("Couldn't connect to: " + | |
56 connectionParams.hostName + ":" + connectionParams.portNumber + | |
57 ": " + e.getMessage()); | |
58 showConnectionErrorDialog("Couldn't connect to: '" + connectionParams.hostName + | |
59 "'\n" + e.getMessage()); | |
60 wasError = true; | |
61 } | |
62 return socket; | |
63 } | |
64 | |
65 | |
66 | |
67 } |