Moved CONNECT_TIMEOUT to Constants.
This commit is contained in:
parent
8e8e530181
commit
72dce163e9
3 changed files with 13 additions and 9 deletions
|
@ -40,6 +40,11 @@ package net.thauvin.erik.mobibot;
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
/**
|
||||||
|
* The connect/read timeout in ms.
|
||||||
|
*/
|
||||||
|
public static final int CONNECT_TIMEOUT = 5000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The empty title string.
|
* The empty title string.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -97,10 +97,6 @@ import java.util.StringTokenizer;
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
@Version(properties = "version.properties", className = "ReleaseInfo")
|
@Version(properties = "version.properties", className = "ReleaseInfo")
|
||||||
public class Mobibot extends PircBot {
|
public class Mobibot extends PircBot {
|
||||||
/**
|
|
||||||
* The connect/read timeout in ms.
|
|
||||||
*/
|
|
||||||
public static final int CONNECT_TIMEOUT = 5000;
|
|
||||||
|
|
||||||
// The default port.
|
// The default port.
|
||||||
private static final int DEFAULT_PORT = 6667;
|
private static final int DEFAULT_PORT = 6667;
|
||||||
|
@ -221,8 +217,10 @@ public class Mobibot extends PircBot {
|
||||||
* @param p The bot's properties.
|
* @param p The bot's properties.
|
||||||
*/
|
*/
|
||||||
public Mobibot(final String nickname, final String channel, final String logsDirPath, final Properties p) {
|
public Mobibot(final String nickname, final String channel, final String logsDirPath, final Properties p) {
|
||||||
System.getProperties().setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(CONNECT_TIMEOUT));
|
System.getProperties().setProperty("sun.net.client.defaultConnectTimeout",
|
||||||
System.getProperties().setProperty("sun.net.client.defaultReadTimeout", String.valueOf(CONNECT_TIMEOUT));
|
String.valueOf(Constants.CONNECT_TIMEOUT));
|
||||||
|
System.getProperties().setProperty("sun.net.client.defaultReadTimeout",
|
||||||
|
String.valueOf(Constants.CONNECT_TIMEOUT));
|
||||||
|
|
||||||
setName(nickname);
|
setName(nickname);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
package net.thauvin.erik.mobibot.modules;
|
package net.thauvin.erik.mobibot.modules;
|
||||||
|
|
||||||
|
import net.thauvin.erik.mobibot.Constants;
|
||||||
import net.thauvin.erik.mobibot.Mobibot;
|
import net.thauvin.erik.mobibot.Mobibot;
|
||||||
import org.apache.commons.net.whois.WhoisClient;
|
import org.apache.commons.net.whois.WhoisClient;
|
||||||
|
|
||||||
|
@ -123,9 +124,9 @@ public final class Lookup extends AbstractModule {
|
||||||
final String[] lines;
|
final String[] lines;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
whoisClient.setDefaultTimeout(Mobibot.CONNECT_TIMEOUT);
|
whoisClient.setDefaultTimeout(Constants.CONNECT_TIMEOUT);
|
||||||
whoisClient.connect(host);
|
whoisClient.connect(host);
|
||||||
whoisClient.setSoTimeout(Mobibot.CONNECT_TIMEOUT);
|
whoisClient.setSoTimeout(Constants.CONNECT_TIMEOUT);
|
||||||
whoisClient.setSoLinger(false, 0);
|
whoisClient.setSoLinger(false, 0);
|
||||||
|
|
||||||
if (host.equals(WHOIS_HOST)) {
|
if (host.equals(WHOIS_HOST)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue