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.19 by ajm, Tue Feb 27 03:09:58 2001 UTC vs.
Revision 1.20 by ajm, Tue Feb 27 23:31:32 2001 UTC

# Line 33 | Line 33 | public class ConnectionHandler extends Thread {
33       * The hardcoded protocol version that we are using.
34       * Used when handshaking with the server
35       */
36 <    public final double PROTOCOL_VERSION = 1.0;
36 >    public final double PROTOCOL_VERSION = 1.1;
37  
38      /**
39       * Thread action DONOTHING.
# Line 144 | Line 144 | public class ConnectionHandler extends Thread {
144       * types.
145       */
146      public void run() {
147 <        if(!_configuration.getProperty("control.onstartconnect").equals("0")) {
147 >        if(_configuration.getProperty("control.onstartconnect").equals("1")) {
148              _actionQueue.add(new Integer(CONNECT));
149          }
150 <        if(!_configuration.getProperty("data.onstartconnect").equals("0")) {
150 >        if(_configuration.getProperty("data.onstartconnect").equals("1")) {
151              _actionQueue.add(new Integer(STARTDATA));
152          }
153          while(_running) {
# Line 220 | Line 220 | public class ConnectionHandler extends Thread {
220                              }
221                              // get the config...we are connected now!
222                              getConfigFromServer();
223 +                            // set our host list if we know we have one we need to set
224 +                            String hostList = _configuration.getProperty("hostList");
225 +                            boolean hostListSet = false;
226 +                            // send our hostList if we have
227 +                            if (_configuration.getProperty("useHostList").equals("1")) {
228 +                                if (hostList.equals("")) {
229 +                                    Conient.addMessage("WARNING{control link}: your host list is empty, the server will send ALL hosts");
230 +                                }
231 +                                hostListSet = setHostList(hostList);
232 +                            // if not, indicate we want the lot                                
233 +                            } else {
234 +                                hostListSet = setHostList("");
235 +                            }
236 +                            // warn if there was a problem, it will have already error'd
237 +                            if (!hostListSet) {
238 +                                Conient.addMessage("WARNING{control link}: unable to set host list");
239 +                            }
240                          } catch (IOException e) {
241                              // print the error and tidy up what's left
242                              Conient.addMessage("ERROR{control link}: " + e);
# Line 467 | Line 484 | public class ConnectionHandler extends Thread {
484   //---PRIVATE METHODS---
485  
486      /**
487 +     * This method performs the SETHOSTLIST command.
488 +     * This is run by the CONNECT command.
489 +     * It tells the server which hosts we are interested
490 +     * in, if "" is sent, this indicates we want ALL hosts.
491 +     *
492 +     * @param hostList the list of hosts as gained from the config
493 +     * @return if we succeeded in setting the host list
494 +     */
495 +    private boolean setHostList(String hostList) {
496 +        boolean success = false;
497 +        // must have a control link open
498 +        if (_controlLink != null) {
499 +            // data link must be closed (according to 1.1 PROTOCOL)
500 +            if(_dataLink == null) {
501 +                try {
502 +                    String response = null;
503 +                    _outBound.println("SETHOSTLIST");
504 +                    _outBound.flush();
505 +                    response = _inBound.readLine();
506 +                    if (!response.equals("OK")) {
507 +                        throw new IOException("server refused - data link possibly still open?");
508 +                    }
509 +                    _outBound.println(hostList);
510 +                    _outBound.flush();
511 +                    response = _inBound.readLine();
512 +                    if (!response.equals("OK")) {
513 +                        throw new IOException("server had trouble with our request");
514 +                    }
515 +                    success = true;
516 +                } catch (IOException e) {
517 +                    Conient.addMessage("ERROR{control link}: when setting hostlist - " + e);
518 +                }
519 +            }
520 +        }
521 +        return success;
522 +    }
523 +
524 +
525 +    /**
526       * This method performs the STARTCONFIG command on
527       * the server. this method is called after a CONNECT,
528       * and when a GETCONFIGURATION command is called.
# Line 525 | Line 581 | public class ConnectionHandler extends Thread {
581          String firewallCommandWait = _configuration.getProperty("firewall.commandwait");
582          String firewallServer = _configuration.getProperty("firewall.server");
583          // if we are running firewall support...then lets start it
584 <        if (!useFirewall.equals("0")) {
584 >        if (useFirewall.equals("1")) {
585              // clean up the command with what we want
586              firewallCommand = replaceText(firewallCommand, "%PORT%", new Integer(port).toString());
587              firewallCommand = replaceText(firewallCommand, "%SERVER%", server);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines