ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/ConnectionHandler.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/ConnectionHandler.java (file contents):
Revision 1.10 by ajm, Wed Jan 24 03:09:46 2001 UTC vs.
Revision 1.11 by ajm, Wed Jan 24 03:21:26 2001 UTC

# Line 133 | Line 133 | public class ConnectionHandler extends Thread {
133                      serverQuestion = JOptionPane.showInputDialog(null, "Please enter the name of a server running the I-Scream client interface:", "I-Scream Server", JOptionPane.INFORMATION_MESSAGE);
134                      if (serverQuestion instanceof String) {
135                          _server = (String) serverQuestion;
136 <                        SwingClient.setControlStatus("Connecting to - " + _server);
136 >                        Conient.setControlStatus("Connecting to - " + _server);
137                          try {
138                              _controlLink = new Socket(_server, _port);
139                              _inBound = new BufferedReader(new InputStreamReader(_controlLink.getInputStream()));
140                              _outBound = new PrintWriter(_controlLink.getOutputStream());
141 <                            SwingClient.setControlStatus("Connection Established - " + _server);
141 >                            Conient.setControlStatus("Connection Established - " + _server);
142                              String response;
143                              response = _inBound.readLine();
144                              if (!(Double.parseDouble(response.substring(10, response.length())) > PROTOCOL_VERSION)) {
145 <                                SwingClient.addMessage("WARNING: server is using a newer protocol (" + response + "), please update your client, continuing with old protocol (PROTOCOL " + PROTOCOL_VERSION + ")" );
145 >                                Conient.addMessage("WARNING: server is using a newer protocol (" + response + "), please update your client, continuing with old protocol (PROTOCOL " + PROTOCOL_VERSION + ")" );
146                              } else if (!(Double.parseDouble(response.substring(10, response.length())) < PROTOCOL_VERSION)) {
147                                  throw new IOException("invalid protocol version");
148                              }
149 <                            SwingClient.addMessage("Handshake Success");
149 >                            Conient.addMessage("Handshake Success");
150                              
151                              // send the name - get from somewhere eventually
152                              _outBound.println(_clientName);
# Line 155 | Line 155 | public class ConnectionHandler extends Thread {
155                              if (!response.equals("OK")) {
156                                  throw new IOException("client name rejected - " + response);
157                              }
158 <                            SwingClient.addMessage("Control Link Established");
158 >                            Conient.addMessage("Control Link Established");
159  
160                          } catch (IOException e) {
161 <                            SwingClient.addMessage("Control Link Error: " + e);
162 <                            SwingClient.setControlStatus("Disconnected");
161 >                            Conient.addMessage("Control Link Error: " + e);
162 >                            Conient.setControlStatus("Disconnected");
163                          }
164                      }
165                      break;
166                  case STARTDATA:
167 <                    SwingClient.addMessage("Attempting to open Data Channel");
167 >                    Conient.addMessage("Attempting to open Data Channel");
168                      try {
169                          if(_controlLink == null) {
170                              _actionQueue.add(new Integer(CONNECT));
# Line 179 | Line 179 | public class ConnectionHandler extends Thread {
179                          // TEMPORARY FIREWALL FIX
180                          // allows user to map an ssh pipe...
181                          JOptionPane.showMessageDialog(null, "WARNING: about to connect to a port you may not have available!\nPlease ensure you have port \"" + response + "\" of your I-Scream server mapped to " + _server, "FIREWALL WARNING!", JOptionPane.INFORMATION_MESSAGE);
182 <                        SwingClient.setDataStatus("Connecting to - " + _server + ":" + response);
182 >                        Conient.setDataStatus("Connecting to - " + _server + ":" + response);
183                          try {
184                              _dataLink = new Socket(_server, Integer.parseInt(response));
185                          } catch (NumberFormatException e) {
# Line 192 | Line 192 | public class ConnectionHandler extends Thread {
192                          }
193                          _dataInBound = new BufferedReader(new InputStreamReader(_dataLink.getInputStream()));
194                          _dataOutBound = new PrintWriter(_dataLink.getOutputStream());
195 <                        SwingClient.setDataStatus("Connection Established - " + _server);
196 <                        SwingClient.addMessage("Data Link connection established");
197 <                        SwingClient.addMessage("Starting data reader");
195 >                        Conient.setDataStatus("Connection Established - " + _server);
196 >                        Conient.addMessage("Data Link connection established");
197 >                        Conient.addMessage("Starting data reader");
198  
199                          // here we will do some connect stuff.
200                          Queue theQueue = new Queue();
# Line 205 | Line 205 | public class ConnectionHandler extends Thread {
205                          _dataReader.start();
206                          // finished for us....
207                      } catch (IOException e) {
208 <                        SwingClient.addMessage("Data Link Error: " + e);
209 <                        SwingClient.setDataStatus("Disconnected");
208 >                        Conient.addMessage("Data Link Error: " + e);
209 >                        Conient.setDataStatus("Disconnected");
210                      }
211                      break;
212                  case STOPDATA:
213 <                    SwingClient.addMessage("Attempting to close Data Channel");
213 >                    Conient.addMessage("Attempting to close Data Channel");
214                      try {
215                          String response;
216                          _outBound.println("STOPDATA");
# Line 221 | Line 221 | public class ConnectionHandler extends Thread {
221                          }
222                          // kill the data reader - we should wait
223                          // for it to die nicely...but we won't yet...we'll kill the socket! ;-p
224 <                        SwingClient.setDataStatus("Disconnecting - " + _server);
224 >                        Conient.setDataStatus("Disconnecting - " + _server);
225                          _dataReader.shutdown();
226                          _dataInBound.close();
227                          _dataOutBound.close();
228                          _dataLink.close();
229                          // get rid of the socket
230                          _dataLink = null;
231 <                        SwingClient.setDataStatus("Disconnected");
232 <                        SwingClient.addMessage("Data Channel closed");
231 >                        Conient.setDataStatus("Disconnected");
232 >                        Conient.addMessage("Data Channel closed");
233                      } catch (IOException e) {
234 <                        SwingClient.addMessage("Data Link Error: " + e);
235 <                        SwingClient.setDataStatus("Unknown");
234 >                        Conient.addMessage("Data Link Error: " + e);
235 >                        Conient.setDataStatus("Unknown");
236                      }
237                      break;
238                  case DISCONNECT:
239 <                    SwingClient.addMessage("Attempting to close Control Channel");
239 >                    Conient.addMessage("Attempting to close Control Channel");
240                      try {
241                          if (_dataLink != null) {
242                              // we want to tell ourselves to stop it
# Line 252 | Line 252 | public class ConnectionHandler extends Thread {
252                              throw new IOException("server didn't OK request to stop control channel");
253                          }
254                          // then lets go!
255 <                        SwingClient.setControlStatus("Disconnecting - " + _server);
255 >                        Conient.setControlStatus("Disconnecting - " + _server);
256                          _inBound.close();
257                          _outBound.close();
258                          _controlLink.close();
259                          // for good measure
260                          _controlLink = null;
261 <                        SwingClient.setControlStatus("Disconnected");
261 >                        Conient.setControlStatus("Disconnected");
262                      } catch (IOException e) {
263 <                        SwingClient.addMessage("Control Link Error: " + e);
264 <                        SwingClient.setControlStatus("Unknown");
263 >                        Conient.addMessage("Control Link Error: " + e);
264 >                        Conient.setControlStatus("Unknown");
265                      }
266                      break;
267                  case QUIT:
268 <                    SwingClient.addMessage("Exiting...");
268 >                    Conient.addMessage("Exiting...");
269                      try {
270                          // stop data and control if data up
271                          if (_dataLink != null) {
# Line 280 | Line 280 | public class ConnectionHandler extends Thread {
280                              _actionQueue.add(new Integer(QUIT));
281                              throw new IOException();
282                          }
283 <                        SwingClient.addMessage("Finished.");
283 >                        Conient.addMessage("Finished.");
284                          // go!
285                          System.exit(0);
286                      } catch (IOException e) {
287 <                        SwingClient.addMessage("Closing connections...");
287 >                        Conient.addMessage("Closing connections...");
288                      }
289                      break;
290              }
# Line 298 | Line 298 | public class ConnectionHandler extends Thread {
298   //---ATTRIBUTES---      
299  
300      boolean _running = true;
301 <    SwingClient SwingClient;
301 >    Conient Conient;
302      DataPanel _data;
303      Queue _actionQueue;
304      int _myQueue;
305      String _server;
306 <    int _port = SwingClient.PORT;
306 >    int _port = Conient.PORT;
307      Socket _controlLink;
308      Socket _dataLink;
309      BufferedReader _inBound;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines