diff --git a/Dorkbox-Network/src/dorkbox/network/Client.java b/Dorkbox-Network/src/dorkbox/network/Client.java
index dbcb6c9c..d6977de0 100644
--- a/Dorkbox-Network/src/dorkbox/network/Client.java
+++ b/Dorkbox-Network/src/dorkbox/network/Client.java
@@ -62,8 +62,6 @@ import java.net.InetSocketAddress;
public
class Client extends EndPointClient implements Connection {
- private final Configuration options;
-
/**
* Starts a LOCAL only client, with the default local channel name and serialization scheme
*/
@@ -87,7 +85,6 @@ class Client extends EndPointClient implements Connection {
public
Client(final Configuration options) throws InitializationException, SecurityException, IOException {
super(options);
- this.options = options;
String threadName = Client.class.getSimpleName();
@@ -109,9 +106,6 @@ class Client extends EndPointClient implements Connection {
options.udtPort = -1;
}
-// tcpBootstrap.setOption(SO_SNDBUF, 1048576);
-// tcpBootstrap.setOption(SO_RCVBUF, 1048576);
-
// setup the thread group to easily ID what the following threads belong to (and their spawned threads...)
SecurityManager s = System.getSecurityManager();
ThreadGroup nettyGroup = new ThreadGroup(s != null
@@ -136,6 +130,10 @@ class Client extends EndPointClient implements Connection {
manageForShutdown(boss);
}
else {
+ if (options.host == null) {
+ throw new IllegalArgumentException("You must define what host you want to connect to.");
+ }
+
if (options.tcpPort > 0) {
Bootstrap tcpBootstrap = new Bootstrap();
this.bootstraps.add(new BootstrapWrapper("TCP", options.tcpPort, tcpBootstrap));
@@ -356,6 +354,7 @@ class Client extends EndPointClient implements Connection {
/**
* Expose methods to send objects to a destination when the connection has become idle.
*/
+ @Override
public
IdleBridge sendOnIdle(IdleSender, ?> sender) {
return this.connectionManager.getConnection0()
@@ -365,6 +364,7 @@ class Client extends EndPointClient implements Connection {
/**
* Expose methods to send objects to a destination when the connection has become idle.
*/
+ @Override
public
IdleBridge sendOnIdle(Object message) {
return this.connectionManager.getConnection0()
@@ -383,14 +383,6 @@ class Client extends EndPointClient implements Connection {
return this.connectionManager.getConnection0();
}
- /**
- * Fetches the host (server) name for this client.
- */
- public
- String getHost() {
- return this.options.host;
- }
-
/**
* Closes all connections ONLY (keeps the server/client running).
*
@@ -427,6 +419,7 @@ class Client extends EndPointClient implements Connection {
*
* @see RemoteObject
*/
+ @Override
public
Iface createRemoteObject(final Class remoteImplementationClass) throws NetException {
return this.connectionManager.getConnection0().createRemoteObject(remoteImplementationClass);
@@ -456,11 +449,9 @@ class Client extends EndPointClient implements Connection {
*
* @see RemoteObject
*/
+ @Override
public
Iface getRemoteObject(final int objectId) throws NetException {
return this.connectionManager.getConnection0().getRemoteObject(objectId);
}
-
-
-
}
diff --git a/Dorkbox-Network/src/dorkbox/network/Configuration.java b/Dorkbox-Network/src/dorkbox/network/Configuration.java
index c2b28b31..9fe13b2a 100644
--- a/Dorkbox-Network/src/dorkbox/network/Configuration.java
+++ b/Dorkbox-Network/src/dorkbox/network/Configuration.java
@@ -21,6 +21,9 @@ import java.util.concurrent.Executor;
public
class Configuration {
+ /**
+ * On the server, if host is null, it will bind to the "any" address, otherwise you must specify the hostname/IP to bind to.
+ */
public String host = null;
public int tcpPort = -1;
diff --git a/Dorkbox-Network/src/dorkbox/network/Server.java b/Dorkbox-Network/src/dorkbox/network/Server.java
index 7afd6970..0f5a8107 100644
--- a/Dorkbox-Network/src/dorkbox/network/Server.java
+++ b/Dorkbox-Network/src/dorkbox/network/Server.java
@@ -152,10 +152,6 @@ class Server extends EndPointServer {
this.udtBootstrap = null;
}
- //TODO: do we need to set the snd/rcv buffer?
-// tcpBootstrap.setOption(SO_SNDBUF, 1048576);
-// tcpBootstrap.setOption(SO_RCVBUF, 1048576);
-
// setup the thread group to easily ID what the following threads belong to (and their spawned threads...)
SecurityManager s = System.getSecurityManager();
ThreadGroup nettyGroup = new ThreadGroup(s != null
@@ -230,6 +226,7 @@ class Server extends EndPointServer {
this.tcpBootstrap.localAddress(this.tcpPort);
}
+
// android screws up on this!!
this.tcpBootstrap.option(ChannelOption.TCP_NODELAY, !Sys.isAndroid);
this.tcpBootstrap.childOption(ChannelOption.TCP_NODELAY, !Sys.isAndroid);
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java
index 07c85305..98e1688b 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java
@@ -173,8 +173,11 @@ class EndPoint {
this.logger = org.slf4j.LoggerFactory.getLogger(type);
+ // The registration wrapper permits the registration process to access protected/package fields/methods, that we don't want
+ // to expose to external code. "this" escaping can be ignored, because it is benign.
+ //noinspection ThisEscapedInObjectConstruction
this.registrationWrapper = new RegistrationWrapper(this,
- this.logger); // TODO - get rid of the wrapper, since it just loops back on itself
+ this.logger);
// make sure that 'localhost' is REALLY our specific IP address
if (options.host != null && (options.host.equals("localhost") || options.host.startsWith("127."))) {
@@ -315,26 +318,6 @@ class EndPoint {
return (T) this.propertyStore;
}
- /**
- * TODO maybe remove this? method call is used by jetty ssl
- *
- * @return the ECC public key in use by this endpoint
- */
- public
- ECPrivateKeyParameters getPrivateKey() {
- return this.privateKey;
- }
-
- /**
- * TODO maybe remove this? method call is used by jetty ssl
- *
- * @return the ECC private key in use by this endpoint
- */
- public
- ECPublicKeyParameters getPublicKey() {
- return this.publicKey;
- }
-
/**
* Internal call by the pipeline to notify the client to continue registering the different session protocols.
* The server does not use this.
@@ -411,7 +394,7 @@ class EndPoint {
*
* @return a new network connection
*/
- public
+ protected
ConnectionImpl newConnection(final Logger logger, final EndPoint endPoint, final RmiBridge rmiBridge) {
return new ConnectionImpl(logger, endPoint, rmiBridge);
}
@@ -522,38 +505,12 @@ class EndPoint {
* Registers a tool with the server, to be used by other services.
*/
public
- void registerTool(EndPointTool toolClass) {
+ void registerTool(T toolClass) {
if (toolClass == null) {
throw new IllegalArgumentException("Tool must not be null! Unable to add tool");
}
- Class>[] interfaces = toolClass.getClass()
- .getInterfaces();
- int length = interfaces.length;
- int index = -1;
-
- if (length > 1) {
- Class> clazz2;
- Class cls = EndPointTool.class;
-
- for (int i = 0; i < length; i++) {
- clazz2 = interfaces[i];
- if (cls.isAssignableFrom(clazz2)) {
- index = i;
- break;
- }
- }
-
- if (index == -1) {
- throw new IllegalArgumentException("Unable to discover tool interface! WHOOPS!");
- }
- }
- else {
- index = 0;
- }
-
- Class> clazz = interfaces[index];
- EndPointTool put = this.toolMap.put(clazz, toolClass);
+ EndPointTool put = this.toolMap.put(toolClass.getClass(), toolClass);
if (put != null) {
throw new IllegalArgumentException("Tool must be unique! Unable to add tool");
}
@@ -563,7 +520,7 @@ class EndPoint {
* Only get the tools in the ModuleStart (ie: load) methods. If done in the constructor, the tool might not be available yet
*/
public
- T getTool(Class> toolClass) {
+ T getTool(Class toolClass) {
if (toolClass == null) {
throw new IllegalArgumentException("Tool must not be null! Unable to add tool");
}
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java b/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java
index cd323cfb..74fe1c90 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java
@@ -68,12 +68,10 @@ class RegistrationWrapper implements UdpServer {
}
}
- public
void setKryoTcpEncoder(KryoEncoder kryoTcpEncoder) {
this.kryoTcpEncoder = kryoTcpEncoder;
}
- public
void setKryoTcpCryptoEncoder(KryoEncoderCrypto kryoTcpCryptoEncoder) {
this.kryoTcpCryptoEncoder = kryoTcpCryptoEncoder;
}