COConfigurationManager.addAndFireParameterListener(
"UDP.Listen.Port",
new ParameterListener()
{
public void
parameterChanged(String name)
{
int port = COConfigurationManager.getIntParameter( name );
if ( port == udp_listen_port ){
return;
}
if ( port < 0 || port > 65535 || port == 6880 ) {
String msg = "Invalid incoming UDP listen port configured, " +port+ ". The port has been reset. Please check your config!";
Debug.out( msg );
Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
udp_listen_port = RandomUtils.generateRandomNetworkListenPort();
COConfigurationManager.setParameter( name, udp_listen_port );
}else{
udp_listen_port = port;
}
}
});
COConfigurationManager.addAndFireParameterListener(
"UDP.NonData.Listen.Port",
new ParameterListener()
{
public void
parameterChanged(String name)
{
int port = COConfigurationManager.getIntParameter( name );
if ( port == udp_non_data_listen_port ){
return;
}
if ( port < 0 || port > 65535 || port == 6880 ) {
String msg = "Invalid incoming UDP non-data listen port configured, " +port+ ". The port has been reset. Please check your config!";
Debug.out( msg );
Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
udp_non_data_listen_port = RandomUtils.generateRandomNetworkListenPort();
COConfigurationManager.setParameter( name, udp_non_data_listen_port );
}else{
udp_non_data_listen_port = port;
}
}
});
connection_manager = new UDPConnectionManager();