return new ConnectActionServerObject(s, key) {
@Override
public void action() throws Exception {
+ long id = getNextId();
try {
for (Object data = rec(); true; data = rec()) {
Object rep = null;
try {
- rep = onRequest(this, data);
+ rep = onRequest(this, data, id);
if (isClosing()) {
return;
}
}
} catch (NullPointerException e) {
// Client has no data any more, we quit
+ onRequestDone(id, getBytesReceived(), getBytesSent());
}
}
* the client action
* @param data
* the data sent by the client (which can be NULL)
+ * @param id
+ * an ID to identify this request (will also be re-used for
+ * {@link ServerObject#onRequestDone(long, long, long)}.
*
* @return the answer to return to the client (which can be NULL)
*
* in case of an exception, the error will only be logged
*/
abstract protected Object onRequest(ConnectActionServerObject action,
- Object data) throws Exception;
+ Object data, long id) throws Exception;
}