Made the connection's IP address available to interesting parties.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2083 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-12-22 06:36:30 +00:00
parent 7f531557be
commit 8ceb0e09e7
2 changed files with 14 additions and 5 deletions
@@ -1,5 +1,5 @@
//
// $Id: Connection.java,v 1.13 2002/11/18 18:53:10 mdb Exp $
// $Id: Connection.java,v 1.14 2002/12/22 06:36:30 mdb Exp $
package com.threerings.presents.server.net;
@@ -82,6 +82,17 @@ public abstract class Connection implements NetEventHandler
return _channel;
}
/**
* Returns a string containing the IP address of the client on the
* other end of this connection or <code>&lt;disconnected&gt;</code>
* if this connection has no underlying socket channel.
*/
public String getIPAddress ()
{
return (_channel == null) ? "<disconnected>" :
String.valueOf(_channel.socket().getInetAddress());
}
/**
* Returns true if this connection is closed.
*/
@@ -1,5 +1,5 @@
//
// $Id: RunningConnection.java,v 1.9 2002/11/18 18:53:10 mdb Exp $
// $Id: RunningConnection.java,v 1.10 2002/12/22 06:36:30 mdb Exp $
package com.threerings.presents.server.net;
@@ -37,9 +37,7 @@ public class RunningConnection extends Connection
public String toString ()
{
String addr = (_channel == null) ? "<disconnected>" :
StringUtil.toString(_channel.socket().getInetAddress());
return "[mode=RUNNING, id=" + (hashCode() % 1000) +
", addr=" + addr + "]";
", addr=" + getIPAddress() + "]";
}
}