X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FConnectActionServer.java;h=10d3440e7af4a4a09e5b7cdf06151ab15ac98f66;hb=a72ea8a7a30837734f7f3f27a4ec7979d2549043;hp=85b46a2fdd89f594528d166f78e26a7177eb8e2c;hpb=79ce1a4973eba079ba819ba841d906de42f38e40;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/server/ConnectActionServer.java b/src/be/nikiroo/utils/serial/server/ConnectActionServer.java index 85b46a2..10d3440 100644 --- a/src/be/nikiroo/utils/serial/server/ConnectActionServer.java +++ b/src/be/nikiroo/utils/serial/server/ConnectActionServer.java @@ -13,6 +13,8 @@ import be.nikiroo.utils.Version; * @author niki */ abstract class ConnectActionServer { + private boolean closing; + /** * The underlying {@link ConnectAction}. *

@@ -77,6 +79,50 @@ abstract class ConnectActionServer { }).start(); } + /** + * Stop the client/server connection on behalf of the server (usually, the + * client connects then is allowed to send as many requests as it wants; in + * some cases, though, the server may wish to forcefully close the + * connection and can do via this value, when it is set to TRUE). + *

+ * Example of usage: the client failed an authentication check, cut the + * connection here and now. + */ + public boolean isClosing() { + return closing; + } + + /** + * Can be called to stop the client/server connection on behalf of the + * server (usually, the client connects then is allowed to send as many + * requests as it wants; in some cases, though, the server may wish to + * forcefully close the connection and can do so by calling this method). + *

+ * Example of usage: the client failed an authentication check, cut the + * connection here and now. + */ + public void close() { + closing = true; + } + + /** + * The total amount of bytes received. + * + * @return the amount of bytes received + */ + public long getBytesReceived() { + return action.getBytesReceived(); + } + + /** + * The total amount of bytes sent. + * + * @return the amount of bytes sent + */ + public long getBytesSent() { + return action.getBytesSent(); + } + /** * Method that will be called when an action is performed on the server. *