67
|
1 package jp.ac.u_ryukyu.treevnc;
|
|
2
|
|
3 import java.util.Map;
|
|
4
|
|
5 import com.glavsoft.viewer.Viewer;
|
|
6 import com.glavsoft.viewer.ViewerImpl;
|
|
7 import com.glavsoft.viewer.mvp.View;
|
|
8 import com.glavsoft.viewer.swing.ConnectionParams;
|
|
9
|
|
10 import jp.ac.u_ryukyu.treevnc.client.EchoClient;
|
|
11 import jp.ac.u_ryukyu.treevnc.client.GetDataClient;
|
|
12 import jp.ac.u_ryukyu.treevnc.client.GetHostClient;
|
|
13
|
|
14 public class CreateConnectionParam {
|
|
15 private String hostName;
|
|
16 private int portNumber;
|
|
17 private MyRfbProto rfb;
|
|
18
|
|
19 public CreateConnectionParam(MyRfbProto rfb) {
|
|
20 this.rfb = rfb;
|
|
21 }
|
|
22
|
|
23 public void communicationToProxy() {
|
|
24 GetHostClient bCast = new GetHostClient("who");
|
|
25 bCast.getHost();
|
|
26 GetDataClient getBcast = new GetDataClient();
|
|
27 Thread runBcast = new Thread(getBcast);
|
|
28 runBcast.start();
|
|
29 hostName = getBcast.textAddress();
|
|
30 portNumber = Integer.parseInt(getBcast.textPort());
|
|
31 getBcast.interrupt();
|
|
32
|
|
33 }
|
|
34
|
|
35 public void createConnectionParam(ViewerImpl v) {
|
|
36 EchoClient echo = new EchoClient(hostName, 9999);
|
|
37 rfb.setEcho(echo);
|
|
38 rfb.setProxyAddr(hostName);
|
|
39 echo.getParentName();
|
|
40 v.setConnectionParam(echo.getParentsAddress(), portNumber);
|
|
41 runAcceptThread();
|
|
42 }
|
|
43
|
|
44
|
|
45 private void runAcceptThread() {
|
|
46 Thread accThread = new Thread(new AcceptThread(rfb, portNumber));
|
|
47 accThread.start();
|
|
48 }
|
|
49
|
|
50 public void setHostName(String _hostName) {
|
|
51 hostName = _hostName;
|
|
52 portNumber = 5999;
|
|
53 }
|
|
54
|
|
55 }
|