We are using smartfox 2x version 2.13.6 for multiplayer functionality on our game.
We would like to find the client's IP in order to find his geo location.
This is the current code:
Code: Select all
public class UserHandler extends BaseClientRequestHandler {
@Override
public void handleClientRequest(User user, ISFSObject sfsObj) {
String ipAdr = user.getIpAddress();
IpGeoLocator geo = new IpGeoLocator();
geo.init("data/", false);
Country country = geo.locateIP(ipAdr);
String country_name="Unknown";
if (country != null) {
country_name = country.getName();
}
}
}
The problem is that the user.getIpAddress() returns 10.2.1.2 which can not be used to track the geo location.
P.S. We have also tried enabling the "use geo location" option on the zone configuration section and called directly user.getCountry() but it returns null.
Thank you ,
Nikos