Get user's ip address

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Get user's ip address

Postby Sparticus » 21 Mar 2006, 21:04

I know I can get it from their user object... but I want to get it before they even log in....

for example.. below is what i'd like to do... but chan doesn't have an getIpAddress() method...

Code: Select all

function handleInternalEvent(evt)
{
   if (evt.name == "loginRequest")
                {
      var chan = evt["chan"]
      trace(chan.getIpAddress());
                }
}


I know when I trace (chan) it has the users ip address in there... but it has allot of other stuff too.... how do i grab just the ip address?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 22 Mar 2006, 10:12

try this:

Code: Select all

chan.socket().getInetAddress().getHostAddress()


chan is an instance of java.nio.channels.SocketChannel
You can read the javadoc here
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 15 guests