tags:

views:

452

answers:

3

I'm trying to find the IP address of a client when they make a particular LCDS service call. Understanding all the issues of getting a "real" IP address and privacy concerns and so on, it is possible to find the client's IP address?

tj

A: 

I think you can get hold of it pretty easily. Not tested, but give it a try.

String ip = FlexContext.getHttpRequest().getRemoteAddr();
Gregor Kiddie
I think that will work for certain kinds of channels, but it doesn't appear to work for RTMP channels. The HTTP request object is null.
Travis Jensen
A: 

I didn't find a way how to do it for all channel types with a simple method call. So I use such code:

    String ip;
    Endpoint clientEndpoint = FlexContext.getEndpoint();
    if (clientEndpoint instanceof RTMPEndpoint) {
       ip = ((RTMPFlexSession)FlexContext.getFlexSession()).getClientInfo().getIp();  
    }
    if ((clientEndpoint instanceof NIOAMFEndpoint) || (clientEndpoint instanceof AMFEndpoint)) {
       ip = FlexContext.getHttpRequest().getRemoteAddr();
    }
Roman
A: 

ip = FlexContext.getHttpRequest().getRemoteAddr();

is gives whoz connected

Thanks Roman

Thirst for Excellence