Mercurial > hg > Members > nobuyasu > tightVNCClient
comparison src/myVncClient/CuiMyVncClient.java @ 67:5e7110277cf0
modify CuiMyVncClient
author | e085711 |
---|---|
date | Sat, 06 Aug 2011 23:23:00 +0900 |
parents | 4225c2fd3e16 |
children | 1f05b73b15df |
comparison
equal
deleted
inserted
replaced
66:9ace9a5e6c9f | 67:5e7110277cf0 |
---|---|
2 | 2 |
3 import java.awt.*; | 3 import java.awt.*; |
4 import java.awt.event.*; | 4 import java.awt.event.*; |
5 import java.io.*; | 5 import java.io.*; |
6 import java.net.*; | 6 import java.net.*; |
7 import java.util.Random; | |
7 | 8 |
8 import myVncClient.AcceptThread; | 9 import myVncClient.AcceptThread; |
9 import myVncClient.OptionsNoFrame; | 10 import myVncClient.OptionsNoFrame; |
10 | 11 |
11 public class CuiMyVncClient implements InterfaceForViewer, java.lang.Runnable { | 12 public class CuiMyVncClient implements InterfaceForViewer, java.lang.Runnable { |
106 recordingActive = false; | 107 recordingActive = false; |
107 recordingStatusChanged = false; | 108 recordingStatusChanged = false; |
108 cursorUpdatesDef = null; | 109 cursorUpdatesDef = null; |
109 eightBitColorsDef = null; | 110 eightBitColorsDef = null; |
110 | 111 |
112 /* | |
113 * try { connectAndAuthenticate(); } catch (NoRouteToHostException e) { | |
114 * fatalError("Network error: no route to server: " + host, e); } catch | |
115 * (UnknownHostException e) { | |
116 * fatalError("Network error: server name unknown: " + host, e); } catch | |
117 * (ConnectException e) { | |
118 * fatalError("Network error: could not connect to server: " + host + | |
119 * ":" + port, e); } catch (Exception e) { } | |
120 */ | |
121 rfbThread = new Thread(this); | |
122 | |
123 } | |
124 | |
125 // | |
126 // run() - executed by the rfbThread to deal with the RFB socket. | |
127 // | |
128 | |
129 public void start_threads() { | |
130 rfbThread.start(); | |
131 } | |
132 | |
133 public void run() { | |
134 | |
111 try { | 135 try { |
112 connectAndAuthenticate(); | 136 connectAndAuthenticate(); |
113 } catch (NoRouteToHostException e) { | 137 accThread = new Thread(new AcceptThread(rfb, 5999)); |
114 fatalError("Network error: no route to server: " + host, e); | 138 accThread.start(); |
115 } catch (UnknownHostException e) { | |
116 fatalError("Network error: server name unknown: " + host, e); | |
117 } catch (ConnectException e) { | |
118 fatalError("Network error: could not connect to server: " + host | |
119 + ":" + port, e); | |
120 } catch (Exception e) { | |
121 } | |
122 | |
123 rfbThread = new Thread(this); | |
124 accThread = new Thread(new AcceptThread(rfb, 5999)); | |
125 | |
126 } | |
127 | |
128 // | |
129 // run() - executed by the rfbThread to deal with the RFB socket. | |
130 // | |
131 | |
132 public void start_threads() { | |
133 rfbThread.start(); | |
134 accThread.start(); | |
135 } | |
136 | |
137 public void run() { | |
138 | |
139 try { | |
140 // connectAndAuthenticate(); | |
141 doProtocolInitialisation(); | 139 doProtocolInitialisation(); |
142 /* | 140 |
143 * htmlFile = new CreateHtmlFile(rfb, host, username); | |
144 * htmlFile.createHtml(); | |
145 */ | |
146 vc = new CuiVncCanvas(this, 0, 0); | 141 vc = new CuiVncCanvas(this, 0, 0); |
147 vc.updateFramebufferSize(); | 142 vc.updateFramebufferSize(); |
143 | |
144 } catch (IOException e) { | |
145 System.out.println("Socket error"); | |
146 // parent no find | |
147 Random rnd = new Random(); | |
148 long ran = rnd.nextInt(5000) + 5000; | |
149 System.out.println(ran); | |
150 // 親がいない場合の処理はここに書く!!!! | |
151 /** | |
152 * this while reconnection | |
153 */ | |
154 | |
155 int counter = 0; | |
156 // window を消してnullを突っ込んでGCで削除させる。 | |
157 /* | |
158 * vncFrame.setVisible(false); vncFrame = null; | |
159 */ | |
160 while (true) { | |
161 /** | |
162 * if my last node case reconnectoion stop | |
163 */ | |
164 | |
165 echo = new EchoClient(echo, this); | |
166 try { | |
167 Thread.sleep(ran); | |
168 } catch (InterruptedException e1) { | |
169 e1.printStackTrace(); | |
170 } | |
171 | |
172 if (counter >= 3) { | |
173 echo.openport(); | |
174 echo.notfoundParent(); | |
175 } | |
176 | |
177 echo.openport(); | |
178 // runflag = echo.losthost(); | |
179 if (echo.losthost()) { | |
180 break; | |
181 } | |
182 counter++; | |
183 } | |
184 | |
185 // System.exit(0); | |
186 } catch (Exception e) { | |
187 System.out.println(e); | |
188 System.exit(0); | |
189 } | |
190 | |
191 try { | |
148 | 192 |
149 processNormalProtocol();// main loop | 193 processNormalProtocol();// main loop |
150 | 194 |
151 } catch (NoRouteToHostException e) { | 195 } catch (NoRouteToHostException e) { |
152 fatalError("Network error: no route to server: " + host, e); | 196 fatalError("Network error: no route to server: " + host, e); |
178 rfb.close(); | 222 rfb.close(); |
179 if (showControls && buttonPanel != null) { | 223 if (showControls && buttonPanel != null) { |
180 buttonPanel.disableButtonsOnDisconnect(); | 224 buttonPanel.disableButtonsOnDisconnect(); |
181 } | 225 } |
182 } else { | 226 } else { |
183 fatalError("Network error: remote side closed connection",e); | 227 fatalError("Network error: remote side closed connection", |
228 e); | |
184 } | 229 } |
185 } | 230 } |
186 } catch (IOException e) { | 231 } catch (IOException e) { |
187 String str = e.getMessage(); | 232 String str = e.getMessage(); |
188 if (str != null && str.length() != 0) { | 233 if (str != null && str.length() != 0) { |