Hi there,
Is there a way to get the smartfoxserver's IP address in a server-side java extension? I have a case where I need to use the server's IP address and I would prefer not to hard-code it.
Alternatively, is it possible to make smartfoxserver listen on more than one address, i.e. loopback and public IP?
thanks!
-zood
get server IP in java extension
IP address can be read with:
This will reflect the setting in the config.xml
Yep, with the latest patch ( 1.5.8 ) SFS binds to both the physical and loopback addresses
cheers
Code: Select all
String ip = SmartFoxServer.SERVER_ADDR
This will reflect the setting in the config.xml
Alternatively, is it possible to make smartfoxserver listen on more than one address, i.e. loopback and public IP?
Yep, with the latest patch ( 1.5.8 ) SFS binds to both the physical and loopback addresses
cheers
IP address can be read with:Code: Select all
String ip = SmartFoxServer.SERVER_ADDR
Hi Lapo,
The above does not work with SmartFox 1.6.0. What will be the right way to get server IP and port number using version 1.6.0? Thank you.
[/quote]
Many of the static settings were moved to a Configuration class in version 1.6
I apologize for not giving any notice about this, we didn't think that those values would be accessed by extension code.
The fully qualified name of the class is called it.gotoandplay.smartfoxserver.config.ConfigData
You can read those two properties like this:
I apologize for not giving any notice about this, we didn't think that those values would be accessed by extension code.
The fully qualified name of the class is called it.gotoandplay.smartfoxserver.config.ConfigData
You can read those two properties like this:
Code: Select all
import it.gotoandplay.smartfoxserver.config.ConfigData;
...
...
String ipAddr = ConfigData.SERVER_ADDR;
int port = ConfigData.SERVER_PORT;
-
- Posts: 6
- Joined: 10 Apr 2020, 11:30
Re: get server IP in java extension
Is there a way to get the smartfoxserver's IP address in a server-side java extension
Re: get server IP in java extension
nitish5221 wrote:Is there a way to get the smartfoxserver's IP address in a server-side java extension
I’d recommend this article:
https://stackoverflow.com/questions/293 ... ss-in-java
see the first solution proposed.
Cheers
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 44 guests