diff --git a/engine/src/networking/com/jme3/network/HostedConnection.java b/engine/src/networking/com/jme3/network/HostedConnection.java index 0e06783ed..8c8e50e15 100644 --- a/engine/src/networking/com/jme3/network/HostedConnection.java +++ b/engine/src/networking/com/jme3/network/HostedConnection.java @@ -47,7 +47,15 @@ public interface HostedConnection extends MessageConnection * Returns the server-unique ID for this client. */ public int getId(); - + + /** + * Returns the transport specific remote address of this connection + * as a string. This may or may not be unique per connection depending + * on the type of transport. It is provided for information and filtering + * purposes. + */ + public String getAddress(); + /** * Closes and removes this connection from the server * sending the optional reason to the remote client. diff --git a/engine/src/networking/com/jme3/network/base/DefaultServer.java b/engine/src/networking/com/jme3/network/base/DefaultServer.java index 0328134ae..a15fc7d15 100644 --- a/engine/src/networking/com/jme3/network/base/DefaultServer.java +++ b/engine/src/networking/com/jme3/network/base/DefaultServer.java @@ -352,7 +352,12 @@ public class DefaultServer implements Server { return id; } - + + public String getAddress() + { + return reliable == null ? null : reliable.getAddress(); + } + public void send( Message message ) { ByteBuffer buffer = MessageProtocol.messageToBuffer(message, null); diff --git a/engine/src/networking/com/jme3/network/kernel/Endpoint.java b/engine/src/networking/com/jme3/network/kernel/Endpoint.java index 56a3d5463..67dde8739 100644 --- a/engine/src/networking/com/jme3/network/kernel/Endpoint.java +++ b/engine/src/networking/com/jme3/network/kernel/Endpoint.java @@ -49,6 +49,13 @@ public interface Endpoint */ public long getId(); + /** + * Returns the transport specific remote address of this endpoint + * as a string. This may or may not be unique per endpoint depending + * on the type of transport. + */ + public String getAddress(); + /** * Returns the kernel to which this endpoint belongs. */ diff --git a/engine/src/networking/com/jme3/network/kernel/tcp/NioEndpoint.java b/engine/src/networking/com/jme3/network/kernel/tcp/NioEndpoint.java index 3e391e85d..e51363e81 100644 --- a/engine/src/networking/com/jme3/network/kernel/tcp/NioEndpoint.java +++ b/engine/src/networking/com/jme3/network/kernel/tcp/NioEndpoint.java @@ -81,6 +81,11 @@ public class NioEndpoint implements Endpoint return id; } + public String getAddress() + { + return String.valueOf(socket.socket().getRemoteSocketAddress()); + } + public boolean isConnected() { return socket.isConnected(); diff --git a/engine/src/networking/com/jme3/network/kernel/udp/UdpEndpoint.java b/engine/src/networking/com/jme3/network/kernel/udp/UdpEndpoint.java index 6228e13d2..9b72e66cd 100644 --- a/engine/src/networking/com/jme3/network/kernel/udp/UdpEndpoint.java +++ b/engine/src/networking/com/jme3/network/kernel/udp/UdpEndpoint.java @@ -86,6 +86,11 @@ public class UdpEndpoint implements Endpoint return id; } + public String getAddress() + { + return String.valueOf(address); + } + public boolean isConnected() { return socket.isConnected();