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.6 by ajm, Mon Jan 22 12:48:38 2001 UTC vs.
Revision 1.7 by tdb, Mon Jan 22 19:35:36 2001 UTC

# Line 27 | Line 27 | public class ConnectionHandler extends Thread {
27       */
28      public final String REVISION = "$Revision$";
29  
30 +
31 +    /**
32 +     * The hardcoded protocol version that we are using.
33 +     * Used when handshaking with the server
34 +     */
35      public final String PROTOCOL_VERSION = "PROTOCOL 1.0";
36  
37 +    /**
38 +     * Thread action DONOTHING.
39 +     * This is an invalid action, but here for completeness
40 +     * if anything sends this action it will warn appropriately
41 +     * but do what it says, ie, nothing ;)
42 +     */
43      public static final int DONOTHING = 0;
44 +    
45 +    /**
46 +     * Thread action CONNECT.
47 +     * Opens the control link to the i-scream server.
48 +     */
49      public static final int CONNECT = 1;
50 +    
51 +    /**
52 +     * Thread action STARTDATA.
53 +     * Opens the data link to the i-scream server
54 +     * and prepares all gui data components for data
55 +     * it then starts all relavant threads going.
56 +     */
57      public static final int STARTDATA = 2;
58 +    
59 +    /**
60 +     * Thread action STOPDATA.
61 +     * Closes the data link and shuts down all components
62 +     * that update gui for various things.
63 +     */
64      public static final int STOPDATA = 3;
65 +    
66 +    /**
67 +     * Thread action DISCONNECT.
68 +     * Checks to see if STOPDATA has been called if not,
69 +     * it will add STOPDATA and then DISCONNECT to
70 +     * the action queue and return.  If STOPDATA has been
71 +     * called it closes down the Control Link and tidies up
72 +     * all relevant threads
73 +     */
74      public static final int DISCONNECT = 4;
75 +    
76 +    /**
77 +     * Thread action QUIT.
78 +     * Checks the status of the two links, if either
79 +     * are still up, it queues the appropriate commands
80 +     * to close them down.  It then System.exit(0)'s!
81 +     */
82      public static final int QUIT = 5;
83  
84   //---STATIC METHODS---
85  
86   //---CONSTRUCTORS---
87  
88 +    /**
89 +     * Constructs new data handler.
90 +     * Needs a reference to the data panel so that
91 +     * it can set it processing inBound data
92 +     * Also gets a reference to the queue that will be
93 +     * used by other areas of the system to send it actions
94 +     *
95 +     * @param data the DataPanel in use
96 +     * @param actionQueue the actionQueue for this class
97 +     */
98      public ConnectionHandler(DataPanel data, Queue actionQueue) {
99          _data = data;
100          _actionQueue = actionQueue;
# Line 48 | Line 103 | public class ConnectionHandler extends Thread {
103      
104   //---PUBLIC METHODS---
105  
106 +
107 +    /**
108 +     * Starts this ConnectionHandler running.
109 +     * This basically runs until told to stop, it gets "actions"
110 +     * from its actionQueue and switch's on them do determine
111 +     * what it should do it then carries out the action
112 +     *
113 +     * For details on what each action does see the action
114 +     * types.
115 +     */
116      public void run() {
117 <              
53 <        while(true) {
117 >        while(_running) {
118              // we wait for a call...
119              int action = 0;
120              try {
# Line 99 | Line 163 | public class ConnectionHandler extends Thread {
163                  case STARTDATA:
164                      SwingClient.addMessage("Attempting to open Data Channel");
165                      try {
166 +                        if(_controlLink == null) {
167 +                            _actionQueue.add(new Integer(CONNECT));
168 +                            _actionQueue.add(new Integer(STARTDATA));
169 +                            throw new IOException("Control Link not establised - queueing start events");
170 +                        }
171                          String response;
172                          _outBound.println("STARTDATA");
173                          _outBound.flush();
# Line 128 | Line 197 | public class ConnectionHandler extends Thread {
197                          Queue theQueue = new Queue();
198                          _dataReader = new DataReader(_dataInBound, theQueue);
199                          _data.setQueue(theQueue);
200 +                        _data.cleanUpTabs();
201                          new Thread(_data).start();
202                          _dataReader.start();
203                          // finished for us....
# Line 224 | Line 294 | public class ConnectionHandler extends Thread {
294  
295   //---ATTRIBUTES---      
296  
297 +    boolean _running = true;
298      SwingClient SwingClient;
299      DataPanel _data;
300      Queue _actionQueue;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines