Browse Source

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

PSp..om 14 năm trước cách đây
mục cha
commit
fd62579bf3

+ 9 - 1
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.

+ 6 - 1
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);

+ 7 - 0
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.
      */

+ 5 - 0
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();

+ 5 - 0
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();