git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix StringUtils test
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
serial
/
server
/
ServerObject.java
diff --git
a/src/be/nikiroo/utils/serial/server/ServerObject.java
b/src/be/nikiroo/utils/serial/server/ServerObject.java
index 0315f90c47f74b19d557e6a029e065da89dd1911..dcd1badd1ad4ade60b87313c3b0960b2b883752e 100644
(file)
--- a/
src/be/nikiroo/utils/serial/server/ServerObject.java
+++ b/
src/be/nikiroo/utils/serial/server/ServerObject.java
@@
-67,11
+67,12
@@
abstract public class ServerObject extends Server {
return new ConnectActionServerObject(s, key) {
@Override
public void action() throws Exception {
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 {
try {
for (Object data = rec(); true; data = rec()) {
Object rep = null;
try {
- rep = onRequest(this, data);
+ rep = onRequest(this, data
, id
);
if (isClosing()) {
return;
}
if (isClosing()) {
return;
}
@@
-83,6
+84,7
@@
abstract public class ServerObject extends Server {
}
} catch (NullPointerException e) {
// Client has no data any more, we quit
}
} catch (NullPointerException e) {
// Client has no data any more, we quit
+ onRequestDone(id, getBytesReceived(), getBytesSent());
}
}
}
}
@@
-93,6
+95,13
@@
abstract public class ServerObject extends Server {
};
}
};
}
+ @Override
+ protected ConnectActionClient getConnectionToMe()
+ throws UnknownHostException, IOException {
+ return new ConnectActionClientObject(new Socket((String) null,
+ getPort()), key);
+ }
+
/**
* This is the method that is called on each client request.
* <p>
/**
* This is the method that is called on each client request.
* <p>
@@
-102,6
+111,9
@@
abstract public class ServerObject extends Server {
* the client action
* @param data
* the data sent by the client (which can be NULL)
* 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)
*
*
* @return the answer to return to the client (which can be NULL)
*
@@
-109,5
+121,5
@@
abstract public class ServerObject extends Server {
* in case of an exception, the error will only be logged
*/
abstract protected Object onRequest(ConnectActionServerObject action,
* 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;
}
}