Added a String getAddress() to the server-side connection

stuff... this will be useful for certain types of filtering
and is good for informational logging.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7030 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent c21ae83fc1
commit fd62579bf3
  1. 10
      engine/src/networking/com/jme3/network/HostedConnection.java
  2. 7
      engine/src/networking/com/jme3/network/base/DefaultServer.java
  3. 7
      engine/src/networking/com/jme3/network/kernel/Endpoint.java
  4. 5
      engine/src/networking/com/jme3/network/kernel/tcp/NioEndpoint.java
  5. 5
      engine/src/networking/com/jme3/network/kernel/udp/UdpEndpoint.java

@ -47,7 +47,15 @@ public interface HostedConnection extends MessageConnection
* Returns the server-unique ID for this client. * Returns the server-unique ID for this client.
*/ */
public int getId(); 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 * Closes and removes this connection from the server
* sending the optional reason to the remote client. * sending the optional reason to the remote client.

@ -352,7 +352,12 @@ public class DefaultServer implements Server
{ {
return id; return id;
} }
public String getAddress()
{
return reliable == null ? null : reliable.getAddress();
}
public void send( Message message ) public void send( Message message )
{ {
ByteBuffer buffer = MessageProtocol.messageToBuffer(message, null); ByteBuffer buffer = MessageProtocol.messageToBuffer(message, null);

@ -49,6 +49,13 @@ public interface Endpoint
*/ */
public long getId(); 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. * Returns the kernel to which this endpoint belongs.
*/ */

@ -81,6 +81,11 @@ public class NioEndpoint implements Endpoint
return id; return id;
} }
public String getAddress()
{
return String.valueOf(socket.socket().getRemoteSocketAddress());
}
public boolean isConnected() public boolean isConnected()
{ {
return socket.isConnected(); return socket.isConnected();

@ -86,6 +86,11 @@ public class UdpEndpoint implements Endpoint
return id; return id;
} }
public String getAddress()
{
return String.valueOf(address);
}
public boolean isConnected() public boolean isConnected()
{ {
return socket.isConnected(); return socket.isConnected();

Loading…
Cancel
Save