36 |
|
|
37 |
|
//---CONSTRUCTORS--- |
38 |
|
|
39 |
< |
public TCPControlHandler(Socket socket, ClientInterfaceServant cli) throws IOException { |
39 |
> |
public TCPControlHandler(Socket socket, Queue queue) throws IOException { |
40 |
|
_socket = socket; |
41 |
< |
_cli = cli; |
41 |
> |
_queue = queue; |
42 |
|
_socketIn = new BufferedReader(new InputStreamReader(_socket.getInputStream())); |
43 |
|
_socketOut = new PrintWriter(_socket.getOutputStream()); |
44 |
|
_logger.write(toString(), Logger.SYSINIT, "created"); |
102 |
|
// call accept() |
103 |
|
Socket s = ss.accept(); |
104 |
|
// when we get the Socket back, give it to the data thread |
105 |
< |
TCPDataHandler dh = new TCPDataHandler(s); |
106 |
< |
// start the data thread (need to be a thread ?) - NO |
107 |
< |
// register the data thread |
108 |
< |
_cli.register(dh); |
105 |
> |
TCPDataHandler dh = new TCPDataHandler(s, _queue); |
106 |
> |
// start it up |
107 |
> |
dh.start(); |
108 |
|
// HOLD a ref to that data thread |
109 |
|
_dataHandler = dh; |
110 |
|
_socketOut.println("OK"); |
118 |
|
} |
119 |
|
else if(cmd.equals("STOPDATA")) { |
120 |
|
if(_dataHandler != null) { |
121 |
< |
// deregister the data thread |
123 |
< |
_cli.deregister(_dataHandler); |
124 |
< |
// SHUT DOWN THE DATA HANDLER ? |
121 |
> |
// Shut down the data handler |
122 |
|
_dataHandler.shutdown(); |
123 |
|
// destroy the reference to it ? |
124 |
|
_dataHandler = null; |
131 |
|
_socketOut.flush(); |
132 |
|
} |
133 |
|
} |
134 |
< |
else if(cmd.equals("END")) { |
134 |
> |
else if(cmd.equals("DISCONNECT")) { |
135 |
|
run=false; |
136 |
|
_socketOut.println("OK"); |
137 |
|
_socketOut.flush(); |
212 |
|
private PrintWriter _socketOut; |
213 |
|
|
214 |
|
/** |
215 |
< |
* A reference to the ClientInterfaceServant. |
215 |
> |
* A reference to the Queue |
216 |
|
*/ |
217 |
< |
private ClientInterfaceServant _cli; |
217 |
> |
private Queue _queue; |
218 |
|
|
219 |
|
private TCPDataHandler _dataHandler; |
220 |
|
|