From 6a73b28b59c2b05c5aee2cb6272f8ceca70dfda7 Mon Sep 17 00:00:00 2001 From: Gideon le Grange Date: Sun, 29 Mar 2015 22:40:01 +0200 Subject: [PATCH] Added command timeouts as requested in #16 --- src/main/java/examples/Config.java | 4 ++-- .../me/legrange/mikrotik/ApiConnection.java | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/examples/Config.java b/src/main/java/examples/Config.java index 57c81aa..7497b21 100644 --- a/src/main/java/examples/Config.java +++ b/src/main/java/examples/Config.java @@ -8,8 +8,8 @@ public class Config { public static final String HOST = "192.168.1.34"; - public static final String USERNAME = "gideon"; - public static final String PASSWORD = "minapp"; + public static final String USERNAME = "admin"; + public static final String PASSWORD = ""; } diff --git a/src/main/java/me/legrange/mikrotik/ApiConnection.java b/src/main/java/me/legrange/mikrotik/ApiConnection.java index b9b6b1e..a69394e 100644 --- a/src/main/java/me/legrange/mikrotik/ApiConnection.java +++ b/src/main/java/me/legrange/mikrotik/ApiConnection.java @@ -25,12 +25,12 @@ public abstract class ApiConnection { * Create a new API connection to the give device on the supplied port, using anonymous TLS for encryption. * @param host The host to which to connect. * @param port The TCP port to use. - * @param timeOut The connection timeout to use when opening the connection. + * @param timeout The connection timeout to use when opening the connection. * @return The ApiConnection * @throws me.legrange.mikrotik.MikrotikApiException Thrown if there is a problem connecting */ - public static ApiConnection connectTLS(String host, int port, int timeOut) throws MikrotikApiException { - return ApiConnectionImpl.connect(host, port, true, timeOut); + public static ApiConnection connectTLS(String host, int port, int timeout) throws MikrotikApiException { + return ApiConnectionImpl.connect(host, port, true, timeout); } @@ -60,12 +60,12 @@ public abstract class ApiConnection { * Create a new API connection to the give device on the supplied port * @param host The host to which to connect. * @param port The TCP port to use. - * @param timeOut The connection timeout to use when opening the connection. + * @param timeout The connection timeout to use when opening the connection. * @return The ApiConnection * @throws me.legrange.mikrotik.MikrotikApiException Thrown if there is a problem connecting */ - public static ApiConnection connect(String host, int port, int timeOut) throws MikrotikApiException { - return ApiConnectionImpl.connect(host, port, false, timeOut); + public static ApiConnection connect(String host, int port, int timeout) throws MikrotikApiException { + return ApiConnectionImpl.connect(host, port, false, timeout); } /** @@ -135,12 +135,22 @@ public abstract class ApiConnection { /** get the command timeout. The command timeout is used to time out API * commands after a specific time. + * + * Note: This is not the same as the timeout value passed in the connect() and + * connectTLS() methods. This timeout is specific to synchronous commands, that + * timeout is applied to opening the API socket. + * * @return The time out in milliseconds. */ public abstract int getTimeout(); /** set the command timeout. The command timeout is used to time out API * commands after a specific time. + * + * Note: This is not the same as the timeout value passed in the connect() and + * connectTLS() methods. This timeout is specific to synchronous commands, that + * timeout is applied to opening the API socket. + * * @param timeout The time out in milliseconds. * @throws MikrotikApiException Thrown if the timeout specified is invalid. */