* @author niki
*/
abstract class ConnectActionServer {
+ private boolean closing;
+
/**
* The underlying {@link ConnectAction}.
* <p>
*
* @param s
* the socket to bind to
+ * @param key
+ * an optional key to encrypt all the communications (if NULL,
+ * everything will be sent in clear text)
*/
- public ConnectActionServer(Socket s) {
- this(s, Version.getCurrentVersion());
+ public ConnectActionServer(Socket s, String key) {
+ this(s, key, Version.getCurrentVersion());
}
/**
*
* @param s
* the socket to bind to
+ * @param key
+ * an optional key to encrypt all the communications (if NULL,
+ * everything will be sent in clear text)
* @param version
* the server version
*/
- public ConnectActionServer(Socket s, Version version) {
- action = new ConnectAction(s, true, version) {
+ public ConnectActionServer(Socket s, String key, Version version) {
+ action = new ConnectAction(s, true, key, version) {
@Override
protected void action(Version clientVersion) throws Exception {
ConnectActionServer.this.action(clientVersion);
}).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).
+ * <p>
+ * Example of usage: the client failed an authentication check, cut the
+ * connection here and now.
+ *
+ * @return TRUE when it is
+ */
+ 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).
+ * <p>
+ * 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.
*