Can I get the client's IP address in an LCDS s

2019-04-14 00:25发布

问题:

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

回答1:

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

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


回答2:

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();
    }


回答3:

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

is gives whoz connected

Thanks Roman



标签: flex lcds