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

喜欢而已 提交于 2019-12-04 16:55:23

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

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

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

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

is gives whoz connected

Thanks Roman

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!