From a824d8fc40edb482d5c8ea45bd749915e8eb8792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius?= Date: Thu, 20 Jul 2017 23:47:24 -0300 Subject: [PATCH] Finishing base docs for all API handler classes --- .../graphenej/api/BaseGrapheneHandler.java | 24 +++++++- .../graphenej/api/GetAccountBalances.java | 31 +++++----- .../graphenej/api/GetAccountByName.java | 24 ++++---- .../graphenej/api/GetAccountHistory.java | 1 + .../graphenej/api/GetAccounts.java | 55 +++++++++--------- .../graphenej/api/GetAllAssetHolders.java | 19 ++++--- .../graphenej/api/GetBlockHeader.java | 26 +++++---- .../graphenej/api/GetKeyReferences.java | 4 +- .../graphenej/api/GetLimitOrders.java | 24 ++++---- .../graphenej/api/GetMarketHistory.java | 52 ++++++++++------- .../graphenej/api/GetObjects.java | 28 +++++++++- .../api/GetRelativeAccountHistory.java | 56 ++++++++++++------- .../graphenej/api/GetRequiredFees.java | 28 +++++----- .../graphenej/api/GetTradeHistory.java | 46 +++++++++++++-- .../graphenej/api/ListAssets.java | 25 ++++++--- .../graphenej/api/LookupAccounts.java | 42 +++++++------- .../graphenej/api/LookupAssetSymbols.java | 22 ++++---- .../api/SubscriptionMessagesHub.java | 27 ++++----- .../api/TransactionBroadcastSequence.java | 25 +++++---- .../graphenej/api/android/NodeConnection.java | 33 ++++++++--- .../api/android/WebsocketWorkerThread.java | 27 +++++++-- 21 files changed, 393 insertions(+), 226 deletions(-) diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java index ea9437b..80d7e2b 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/BaseGrapheneHandler.java @@ -12,8 +12,6 @@ import de.bitsharesmunich.graphenej.models.BaseResponse; /** * Base class that should be extended by any implementation of a specific request to the full node. - * - * Created by nelson on 1/5/17. */ public abstract class BaseGrapheneHandler extends WebSocketAdapter { @@ -32,9 +30,22 @@ public abstract class BaseGrapheneHandler extends WebSocketAdapter { */ protected long requestId; + /** + * Constructor (The original constructor, should be replaced with the one that receives + * NodeErrorListener instead of WitnessResponseListener) + * + * @param listener listener to be notified in if an error occurs + */ + @Deprecated public BaseGrapheneHandler(WitnessResponseListener listener){ this.mListener = listener; } + + /** + * Constructor + * + * @param listener listener to be notified if an error occurs + */ public BaseGrapheneHandler(NodeErrorListener listener){ this.mErrorListener = listener; } @@ -52,7 +63,14 @@ public abstract class BaseGrapheneHandler extends WebSocketAdapter { for (StackTraceElement element : cause.getStackTrace()){ System.out.println(element.getFileName()+"#"+element.getClassName()+":"+element.getLineNumber()); } - mErrorListener.onError(new BaseResponse.Error(cause.getMessage())); + // Should be replaced for mErrorListener (NodeErrorListener type) only in the future + if(mErrorListener != null){ + mErrorListener.onError(new BaseResponse.Error(cause.getMessage())); + } + else{ + mListener.onError(new BaseResponse.Error(cause.getMessage())); + } + websocket.disconnect(); } diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java index 1d8a5d7..41f6287 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountBalances.java @@ -23,11 +23,10 @@ import java.util.Map; * * Get an account’s balances in various assets. * - * The request returns the balances of the account + * The response returns the balances of the account * * @see get_account_balances API doc * - * Created by nelson on 1/13/17. */ public class GetAccountBalances extends BaseGrapheneHandler { @@ -38,13 +37,14 @@ public class GetAccountBalances extends BaseGrapheneHandler { /** * Default Constructor * - * @param userAccount account to get balances for - * @param assets list of the assets to get balances of; if empty, get all assets account has a balance in - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param userAccount account to get balances for + * @param assets list of the assets to get balances of; if empty, get all assets account + * has a balance in + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccountBalances(UserAccount userAccount, List assets, boolean oneTime, WitnessResponseListener listener) { super(listener); @@ -54,13 +54,14 @@ public class GetAccountBalances extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. + * Using this constructor the WebSocket connection closes after the response. * - * @param userAccount account to get balances for - * @param assets list of the assets to get balances of; if empty, get all assets account has a balance in - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param userAccount account to get balances for + * @param assets list of the assets to get balances of; if empty, get all assets account + * has a balance in + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccountBalances(UserAccount userAccount, List assets, WitnessResponseListener listener) { this(userAccount, assets, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java index 4998c40..d11634f 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountByName.java @@ -24,7 +24,7 @@ import de.bitsharesmunich.graphenej.models.WitnessResponse; * * Get an account’s info by name. * - * The request returns account data that refer to the name. + * The response returns account data that refer to the name. * * @see get_account_by_name API doc */ @@ -37,12 +37,12 @@ public class GetAccountByName extends BaseGrapheneHandler { /** * Default Constructor * - * @param accountName name of the account to get info - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param accountName name of the account to get info + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccountByName(String accountName, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -52,12 +52,12 @@ public class GetAccountByName extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. + * Using this constructor the WebSocket connection closes after the response. * - * @param accountName name of the account to get info - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param accountName name of the account to get info + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccountByName(String accountName, WitnessResponseListener listener){ this(accountName, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java index 1c1db62..061cedc 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccountHistory.java @@ -3,5 +3,6 @@ package de.bitsharesmunich.graphenej.api; /** * Created by nelson on 12/26/16. */ +//TODO: Implement if needed: http://docs.bitshares.eu/api/history.html?highlight=get_market_history#account-history-api public class GetAccountHistory { } diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java index aa14bc3..9350ee5 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAccounts.java @@ -25,7 +25,7 @@ import de.bitsharesmunich.graphenej.models.WitnessResponse; * * Get a list of accounts by ID. * - * The request returns the accounts corresponding to the provided IDs. + * The response returns the accounts corresponding to the provided IDs. * * @see get_accounts API doc */ @@ -36,13 +36,14 @@ public class GetAccounts extends BaseGrapheneHandler { private boolean mOneTime; /** - * Default Constructor - * @param accountId ID of the account to retrieve - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Constructor for one account only. + * + * @param accountId ID of the account to retrieve + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccounts(String accountId, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -52,13 +53,14 @@ public class GetAccounts extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. - * @param accounts list with the accounts to retrieve - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Constructor for account list. + * + * @param accounts list with the accounts to retrieve + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccounts(List accounts, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -68,22 +70,25 @@ public class GetAccounts extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. - * @param accountId ID of the account to retrieve - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Using this constructor the WebSocket connection closes after the response. (Account based) + * + * @param accountId ID of the account to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccounts(String accountId, WitnessResponseListener listener){ this(accountId, true, listener); } /** - * Using this constructor the websocket connection closes after the response. - * @param accounts list with the accounts to retrieve - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Using this constructor the WebSocket connection closes after the response. (Account List + * based) + * + * @param accounts list with the accounts to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAccounts(List accounts, WitnessResponseListener listener){ this(accounts, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java index 26f10f1..4147bc5 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetAllAssetHolders.java @@ -20,9 +20,9 @@ import java.util.Map; * * Get a list of all system assets with holders count. * - * The request returns the list of all assets with holders count. + * The response returns the list of all assets with holders count. * - * @see get_all_asset_holders API doc + * @see get_all_asset_holders API doc (source code ref.) */ public class GetAllAssetHolders extends BaseGrapheneHandler { private final static int LOGIN_ID = 1; @@ -35,12 +35,13 @@ public class GetAllAssetHolders extends BaseGrapheneHandler { private boolean mOneTime; /** - * Constructor - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Default Constructor + * + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetAllAssetHolders(boolean oneTime, WitnessResponseListener listener) { super(listener); @@ -48,7 +49,7 @@ public class GetAllAssetHolders extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. + * Using this constructor the WebSocket connection closes after the response. * * @param listener A class implementing the WitnessResponseListener interface. This should * be implemented by the party interested in being notified about the success/failure diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java index 02d08a0..cb59103 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetBlockHeader.java @@ -43,13 +43,14 @@ public class GetBlockHeader extends BaseGrapheneHandler { private boolean mOneTime; /** - * Constructor - * @param blockNumber height of the block whose header should be returned - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Default Constructor + * + * @param blockNumber height of the block whose header should be returned + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetBlockHeader(long blockNumber, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -59,11 +60,12 @@ public class GetBlockHeader extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. - * @param blockNumber height of the block whose header should be returned - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Using this constructor the WebSocket connection closes after the response. + * + * @param blockNumber height of the block whose header should be returned + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetBlockHeader(long blockNumber, WitnessResponseListener listener){ this(blockNumber, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java index d32b1d0..576d6a6 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetKeyReferences.java @@ -37,7 +37,7 @@ public class GetKeyReferences extends BaseGrapheneHandler { * Constructor * * @param address address to be query - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not (false) * after the response * @param listener A class implementing the WitnessResponseListener interface. This should * be implemented by the party interested in being notified about the success/failure @@ -53,7 +53,7 @@ public class GetKeyReferences extends BaseGrapheneHandler { /** * * @param addresses list of addresses to be query - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not (false) * after the response * @param listener A class implementing the WitnessResponseListener interface. This should * be implemented by the party interested in being notified about the success/failure diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java index f399f0e..9fa7236 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java @@ -47,11 +47,11 @@ public class GetLimitOrders extends BaseGrapheneHandler { * @param a id of asset being sold * @param b id of asset being purchased * @param limit maximum number of orders to retrieve - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetLimitOrders(String a, String b, int limit, boolean oneTime, WitnessResponseListener listener) { super(listener); @@ -63,14 +63,14 @@ public class GetLimitOrders extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. + * Using this constructor the WebSocket connection closes after the response. * - * @param a id of asset being sold - * @param b id of asset being purchased - * @param limit maximum number of orders to retrieve - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param a id of asset being sold + * @param b id of asset being purchased + * @param limit maximum number of orders to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetLimitOrders(String a, String b, int limit, WitnessResponseListener listener) { this(a, b, limit, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java index 07b65d0..bb6be94 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetMarketHistory.java @@ -25,6 +25,7 @@ import de.bitsharesmunich.graphenej.models.WitnessResponse; /** * Class that implements get_market_history request handler. * + * Get mar * * @see get_market_history API doc * @@ -51,18 +52,23 @@ public class GetMarketHistory extends BaseGrapheneHandler { private boolean mOneTime; /** - * Constructor + * Default Constructor * - * @param base - * @param quote - * @param bucket - * @param start - * @param end - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener a class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param base asset which history is desired + * @param quote asset which the base price asset will be compared to + * @param bucket the time interval (in seconds) for each point should be (analog to + * candles on a candle stick graph). + * Note: The bucket value is discrete and node dependent. The default value + * is 3600s. To get the available buckets of a node use + * get_all_asset_holders API call. + * @param start datetime of of the most recent operation to retrieve (Note: The name is + * counter intuitive, but it follow the original API parameter name) + * @param end datetime of the the earliest operation to retrieve + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetMarketHistory(Asset base, Asset quote, long bucket, Date start, Date end, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -76,15 +82,21 @@ public class GetMarketHistory extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. + * Using this constructor the WebSocket connection closes after the response. * - * @param base - * @param quote - * @param bucket - * @param start - * @param end - * @param listener a class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure + * @param base asset which history is desired + * @param quote asset which the base price asset will be compared to + * @param bucket the time interval (in seconds) for each point should be (analog to + * candles on a candle stick graph). + * Note: The bucket value is discrete and node dependent. The default value + * is 3600s. To get the available buckets of a node use + * get_all_asset_holders API call. + * @param start datetime of of the most recent operation to retrieve (Note: The name is + * counter intuitive, but it follow the original API parameter name) + * @param end datetime of the the earliest operation to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetMarketHistory(Asset base, Asset quote, long bucket, Date start, Date end, WitnessResponseListener listener){ this(base, quote, bucket, start, end, true, listener); @@ -135,7 +147,7 @@ public class GetMarketHistory extends BaseGrapheneHandler { } public void disconnect(){ - if(mWebsocket != null && mWebsocket.isOpen() && mOneTime){ + if(mWebsocket != null && mWebsocket.isOpen()){ mWebsocket.disconnect(); } } diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java index e507186..9c34966 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetObjects.java @@ -28,19 +28,45 @@ import de.bitsharesmunich.graphenej.models.BitAssetData; import de.bitsharesmunich.graphenej.models.WitnessResponse; /** - * Created by nelson on 1/8/17. + * + * Class that implements get_objects request handler. + * + * Get the objects corresponding to the provided IDs. + * + * The response returns a list of objects retrieved, in the order they are mentioned in ids + * + * @see get_objects API doc + * */ public class GetObjects extends BaseGrapheneHandler { private List ids; private boolean mOneTime; + /** + * Default Constructor + * + * @param ids list of IDs of the objects to retrieve + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. + */ public GetObjects(List ids, boolean oneTime, WitnessResponseListener listener){ super(listener); this.ids = ids; this.mOneTime = oneTime; } + /** + * Using this constructor the WebSocket connection closes after the response. + * + * @param ids list of IDs of the objects to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. + */ public GetObjects(List ids, WitnessResponseListener listener){ this(ids, true, listener); } diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java index b0d299b..c26f2be 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRelativeAccountHistory.java @@ -52,12 +52,16 @@ public class GetRelativeAccountHistory extends BaseGrapheneHandler { /** * Constructor that takes all possible parameters. - * @param userAccount The user account to be queried - * @param stop Sequence number of earliest operation - * @param limit Maximum number of operations to retrieve (must not exceed 100) - * @param start Sequence number of the most recent operation to retrieve - * @param oneTime Boolean value indicating if websocket must be closed or not after request - * @param listener Listener to be notified with the result of this query + * + * @param userAccount The user account to be queried + * @param stop Sequence number of earliest operation + * @param limit Maximum number of operations to retrieve (must not exceed 100) + * @param start Sequence number of the most recent operation to retrieve + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetRelativeAccountHistory(UserAccount userAccount, int stop, int limit, int start, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -72,9 +76,13 @@ public class GetRelativeAccountHistory extends BaseGrapheneHandler { /** * Constructor that uses the default values, and sets the limit to its maximum possible value. - * @param userAccount The user account to be queried - * @param oneTime Boolean value indicating if websocket must be closed or not after request - * @param listener Listener to be notified with the result of this query + * + * @param userAccount The user account to be queried + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetRelativeAccountHistory(UserAccount userAccount, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -87,12 +95,16 @@ public class GetRelativeAccountHistory extends BaseGrapheneHandler { } /** - * Constructor that takes all possible parameters except for oneTime (which will be always true here) - * @param userAccount The user account to be queried - * @param stop Sequence number of earliest operation - * @param limit Maximum number of operations to retrieve (must not exceed 100) - * @param start Sequence number of the most recent operation to retrieve - * @param listener Listener to be notified with the result of this query + * Constructor that takes all possible parameters for the query. + * Using this constructor the WebSocket connection closes after the response. + * + * @param userAccount The user account to be queried + * @param stop Sequence number of earliest operation + * @param limit Maximum number of operations to retrieve (must not exceed 100) + * @param start Sequence number of the most recent operation to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetRelativeAccountHistory(UserAccount userAccount, int stop, int limit, int start, WitnessResponseListener listener){ this(userAccount, stop, limit, start, true, listener); @@ -100,9 +112,12 @@ public class GetRelativeAccountHistory extends BaseGrapheneHandler { /** * Constructor that uses the default values, and sets the limit to its maximum possible value. - * oneTime is always set to true at this constructor. - * @param userAccount The user account to be queried - * @param listener Listener to be notified with the result of this query + * Using this constructor the WebSocket connection closes after the response. + * + * @param userAccount The user account to be queried + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetRelativeAccountHistory(UserAccount userAccount, WitnessResponseListener listener){ this(userAccount, true, listener); @@ -167,7 +182,8 @@ public class GetRelativeAccountHistory extends BaseGrapheneHandler { } /** - * Updates the arguments and makes a new call to the get_relative_account_history API + * Updates the arguments and makes a new call to the get_relative_account_history API. + * * @param stop Sequence number of earliest operation * @param limit Maximum number of operations to retrieve (must not exceed 100) * @param start Sequence number of the most recent operation to retrieve @@ -180,7 +196,7 @@ public class GetRelativeAccountHistory extends BaseGrapheneHandler { } /** - * Disconnects the websocket + * Disconnects the WebSocket. */ public void disconnect(){ if(mWebsocket != null && mWebsocket.isOpen() && mOneTime){ diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java index 3c9fd54..553c95d 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetRequiredFees.java @@ -38,15 +38,15 @@ public class GetRequiredFees extends BaseGrapheneHandler { private boolean mOneTime; /** - * Constructor + * Default Constructor * - * @param operations list of operations that fee should be calculated - * @param asset specify the asset of the operations - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param operations list of operations that fee should be calculated + * @param asset specify the asset of the operations + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetRequiredFees(List operations, Asset asset, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -57,13 +57,13 @@ public class GetRequiredFees extends BaseGrapheneHandler { } /** - * Using this constructor the websocket connection closes after the response. + * Using this constructor the WebSocket connection closes after the response. * - * @param operations list of operations that fee should be calculated - * @param asset specify the asset of the operations - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param operations list of operations that fee should be calculated + * @param asset specify the asset of the operations + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public GetRequiredFees(List operations, Asset asset, WitnessResponseListener listener){ this(operations, asset, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java index d8166a0..dde5665 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/GetTradeHistory.java @@ -18,7 +18,15 @@ import de.bitsharesmunich.graphenej.models.ApiCall; import de.bitsharesmunich.graphenej.models.WitnessResponse; /** - * @author henry + * Class that implements get_trade_history request handler. + * + * Get recent trades for the market assetA:assetB for a time interval + * Note: Currently, timezone offsets are not supported. The time must be UTC. + * + * The request returns the all trades of the passed pair of asset at a specific time interval. + * + * @see get_trade_history API doc + * */ public class GetTradeHistory extends BaseGrapheneHandler { @@ -31,19 +39,45 @@ public class GetTradeHistory extends BaseGrapheneHandler { private boolean mOneTime; - public GetTradeHistory(String a, String b, String toTime, String fromTime,int limit, boolean oneTime, WitnessResponseListener mListener) { - super(mListener); + /** + * Constructor + * + * @param a name of the first asset + * @param b name of the second asset + * @param toTime stop time as a UNIX timestamp + * @param fromTime start time as a UNIX timestamp + * @param limit number of transactions to retrieve, capped at 100 + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. + */ + public GetTradeHistory(String a, String b, String toTime, String fromTime,int limit, boolean oneTime, WitnessResponseListener listener) { + super(listener); this.a = a; this.b = b; this.toTime = toTime; this.fromTime = fromTime; this.limit = limit; this.mOneTime = oneTime; - this.mListener = mListener; + this.mListener = listener; } - public GetTradeHistory(String a, String b, String toTime, String fromTime,int limit, WitnessResponseListener mListener) { - this(a, b, toTime, fromTime, limit, true, mListener); + /** + * Using this constructor the WebSocket connection closes after the response. + * + * @param a name of the first asset + * @param b name of the second asset + * @param toTime stop time as a UNIX timestamp + * @param fromTime start time as a UNIX timestamp + * @param limit number of transactions to retrieve, capped at 100 + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. + */ + public GetTradeHistory(String a, String b, String toTime, String fromTime,int limit, WitnessResponseListener listener) { + this(a, b, toTime, fromTime, limit, true, listener); } @Override diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java index cd3f1a6..28fb6bb 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/ListAssets.java @@ -19,13 +19,12 @@ import java.util.Map; /** * WebSocketAdapter class used to send a request a 'list_assets' API call to the witness node. * - * @see: - * * The API imposes a limit of of 100 assets per request, but if the user of this class wants * to get a list of all assets, the LIST_ALL constant must be used as second argument in the * constructor. Internally we are going to perform multiple calls in order to satisfy the user's * request. * + * @see: */ public class ListAssets extends BaseGrapheneHandler { /** @@ -49,9 +48,14 @@ public class ListAssets extends BaseGrapheneHandler { /** * Constructor * - * @param lowerBoundSymbol: Lower bound of symbol names to retrieve - * @param limit: Maximum number of assets to fetch, if the constant LIST_ALL - * is passed, all existing assets will be retrieved. + * @param lowerBoundSymbol Lower bound of symbol names to retrieve + * @param limit Maximum number of assets to fetch, if the constant LIST_ALL + * is passed, all existing assets will be retrieved. + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This + * should be implemented by the party interested in being notified + * about the success/failure of the operation. */ public ListAssets(String lowerBoundSymbol, int limit, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -63,9 +67,14 @@ public class ListAssets extends BaseGrapheneHandler { /** * Using this constructor the WebSocket connection closes after the response. * - * @param lowerBoundSymbol: Lower bound of symbol names to retrieve - * @param limit: Maximum number of assets to fetch, if the constant LIST_ALL - * is passed, all existing assets will be retrieved. + * @param lowerBoundSymbol Lower bound of symbol names to retrieve + * @param limit Maximum number of assets to fetch, if the constant LIST_ALL + * is passed, all existing assets will be retrieved. + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This + * should be implemented by the party interested in being notified + * about the success/failure of the operation. */ public ListAssets(String lowerBoundSymbol, int limit, WitnessResponseListener listener){ this(lowerBoundSymbol, limit, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java index 2ca951f..97ab2bf 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAccounts.java @@ -38,12 +38,12 @@ public class LookupAccounts extends BaseGrapheneHandler { /** * Constructor * - * @param accountName account name used at the query - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param accountName account name used at the query + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public LookupAccounts(String accountName, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -56,13 +56,13 @@ public class LookupAccounts extends BaseGrapheneHandler { /** * Constructor with maxAccounts * - * @param accountName account name used at the query - * @param maxAccounts maximum number of results to return (must not exceed 1000) - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param accountName account name used at the query + * @param maxAccounts maximum number of results to return (must not exceed 1000) + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public LookupAccounts(String accountName, int maxAccounts, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -75,10 +75,10 @@ public class LookupAccounts extends BaseGrapheneHandler { /** * Using this constructor the WebSocket connection closes after the response. * - * @param accountName account name used at the query - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param accountName account name used at the query + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public LookupAccounts(String accountName, WitnessResponseListener listener){ this(accountName, true, listener); @@ -87,9 +87,11 @@ public class LookupAccounts extends BaseGrapheneHandler { /** * Using this constructor the WebSocket connection closes after the response. * - * @param accountName account name used at the query - * @param maxAccounts maximum number of results to return (must not exceed 1000) - * @param listener + * @param accountName account name used at the query + * @param maxAccounts maximum number of results to return (must not exceed 1000) + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public LookupAccounts(String accountName, int maxAccounts, WitnessResponseListener listener){ this(accountName, maxAccounts, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java index 186a74e..288c0e9 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/LookupAssetSymbols.java @@ -33,14 +33,14 @@ public class LookupAssetSymbols extends BaseGrapheneHandler { private boolean mOneTime; /** - * Constructor + * Default Constructor * - * @param assets list of the assets to retrieve - * @param oneTime boolean value indicating if websocket must be closed (true) or not (false) - * after the response - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param assets list of the assets to retrieve + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public LookupAssetSymbols(List assets, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -52,10 +52,10 @@ public class LookupAssetSymbols extends BaseGrapheneHandler { /** * Using this constructor the WebSocket connection closes after the response. * - * @param assets list of the assets to retrieve - * @param listener A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * @param assets list of the assets to retrieve + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public LookupAssetSymbols(List assets, WitnessResponseListener listener){ this(assets, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/SubscriptionMessagesHub.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/SubscriptionMessagesHub.java index 780564d..bf80165 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/SubscriptionMessagesHub.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/SubscriptionMessagesHub.java @@ -31,8 +31,6 @@ import de.bitsharesmunich.graphenej.operations.TransferOperation; /** * A WebSocket adapter prepared to be used as a basic dispatch hub for subscription messages. - * - * Created by nelson on 1/26/17. */ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements SubscriptionHub { @@ -73,10 +71,11 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs * * A list of ObjectTypes must be provided, otherwise we won't get any update. * - * @param user: User name, in case the node to which we're going to connect to requires authentication - * @param password: Password, same as above - * @param clearFilter: Whether to automatically subscribe of not to the notification feed. - * @param errorListener: Callback that will be fired in case there is an error. + * @param user User name, in case the node to which we're going to connect to requires + * authentication + * @param password Password, same as above + * @param clearFilter Whether to automatically subscribe of not to the notification feed. + * @param errorListener Callback that will be fired in case there is an error. */ public SubscriptionMessagesHub(String user, String password, boolean clearFilter, NodeErrorListener errorListener){ super(errorListener); @@ -96,13 +95,14 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs } /** - * Constructor used to create a subscription message hub that will call the set_subscribe_callback - * API with the clear_filter parameter set to false, meaning that it will only receive updates - * from objects we register. + * Constructor used to create a subscription message hub that will call the + * set_subscribe_callback API with the clear_filter parameter set to false, meaning that it will + * only receive updates from objects we register. * - * @param user: User name, in case the node to which we're going to connect to requires authentication - * @param password: Password, same as above - * @param errorListener: Callback that will be fired in case there is an error. + * @param user User name, in case the node to which we're going to connect to requires + * authentication + * @param password Password, same as above + * @param errorListener Callback that will be fired in case there is an error. */ public SubscriptionMessagesHub(String user, String password, NodeErrorListener errorListener){ this(user, password, false, errorListener); @@ -246,7 +246,8 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs /** * Method used to check the current state of the connection. - * @return: True if the websocket is open and there is an active subscription, false otherwise. + * + * @return True if the websocket is open and there is an active subscription, false otherwise. */ public boolean isSubscribed(){ return this.mWebsocket.isOpen() && isSubscribed; diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/TransactionBroadcastSequence.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/TransactionBroadcastSequence.java index cd4161e..6064df5 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/TransactionBroadcastSequence.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/TransactionBroadcastSequence.java @@ -46,12 +46,14 @@ public class TransactionBroadcastSequence extends BaseGrapheneHandler { private boolean mOneTime; /** - * Constructor of this class. The ids required - * @param transaction: The transaction to be broadcasted. - * @param oneTime Boolean value indicating if websocket must be closed or not after request - * @param listener: A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Default Constructor + * + * @param transaction transaction to be broadcasted. + * @param oneTime boolean value indicating if WebSocket must be closed (true) or not + * (false) after the response + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public TransactionBroadcastSequence(Transaction transaction, Asset feeAsset, boolean oneTime, WitnessResponseListener listener){ super(listener); @@ -62,11 +64,12 @@ public class TransactionBroadcastSequence extends BaseGrapheneHandler { } /** - * Constructor of this class with oneTime=true - * @param transaction: The transaction to be broadcasted. - * @param listener: A class implementing the WitnessResponseListener interface. This should - * be implemented by the party interested in being notified about the success/failure - * of the transaction broadcast operation. + * Using this constructor the WebSocket connection closes after the response. + * + * @param transaction: transaction to be broadcasted. + * @param listener A class implementing the WitnessResponseListener interface. This should + * be implemented by the party interested in being notified about the + * success/failure of the operation. */ public TransactionBroadcastSequence(Transaction transaction, Asset feeAsset, WitnessResponseListener listener){ this(transaction, feeAsset, true, listener); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/NodeConnection.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/NodeConnection.java index 54be1ce..3bd90e8 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/NodeConnection.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/NodeConnection.java @@ -11,9 +11,11 @@ import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener; import de.bitsharesmunich.graphenej.models.BaseResponse; /** - * Created by nelson on 6/26/17. + * Class used to encapsulate all connections that should be done to a node (with node hop support). + * + * This class is intended to be used as a central broker for all full node API requests. It should + * be used as a singleton under an application. */ - public class NodeConnection { /** * List of URLs of the nodes @@ -35,7 +37,7 @@ public class NodeConnection { private boolean mSubscribe; /* - * Ger the instance of the NodeConnection which is inteded to be used as a Singleton. + * Get the instance of the NodeConnection which is intended to be used as a Singleton. */ public static NodeConnection getInstance(){ if(instance == null){ @@ -49,7 +51,7 @@ public class NodeConnection { } /** - * Add a websocket URL node that will be added to the list used at node hop scheme. + * Add a WebSocket URL node that will be added to the list used at node hop scheme. * * @param url: URL of the node */ @@ -59,7 +61,7 @@ public class NodeConnection { } /** - * Add a list of websocket URL nodes that will be added to the current list and + * Add a list of WebSocket URL nodes that will be added to the current list and * be used at node hop scheme. * * @param urlList: List of URLs of the nodes @@ -70,7 +72,7 @@ public class NodeConnection { } /** - * Get the list of websocket URL nodes. + * Get the list of WebSocket URL nodes. * * @return List of URLs of the nodes */ @@ -79,7 +81,7 @@ public class NodeConnection { } /** - * Clear list of websocket URL nodes. + * Clear list of WebSocket URL nodes. */ public void clearNodeList(){ this.mUrlList.clear(); @@ -94,10 +96,22 @@ public class NodeConnection { } }; + /** + + */ /** * Method that will try to connect to one of the nodes. If the connection fails * a subsequent call to this method will try to connect with the next node in the * list if there is one. + * + * @param user user credential used for restricted requested that needed to be + * logged + * @param password password credential used for restricted requested that needed to be + * logged + * @param subscribe if the node should be subscribed to the node + * @param errorListener a class implementing the WitnessResponseListener interface. This + * should be implemented by the party interested in being notified + * about the failure of the desired broadcast operation. */ public void connect(String user, String password, boolean subscribe, WitnessResponseListener errorListener) { if(this.mUrlList.size() > 0){ @@ -116,7 +130,10 @@ public class NodeConnection { } /** - * Add the API Handler to the node. + * Add the API Handler to the node. + * + * @param handler request handler to be added to the connection + * @throws RepeatedRequestIdException */ public void addRequestHandler(BaseGrapheneHandler handler) throws RepeatedRequestIdException { handler.setRequestId(requestCounter); diff --git a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/WebsocketWorkerThread.java b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/WebsocketWorkerThread.java index d14a0b2..76db5e0 100644 --- a/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/WebsocketWorkerThread.java +++ b/graphenej/src/main/java/de/bitsharesmunich/graphenej/api/android/WebsocketWorkerThread.java @@ -15,7 +15,8 @@ import de.bitsharesmunich.graphenej.models.BaseResponse; import de.bitsharesmunich.graphenej.test.NaiveSSLContext; /** - * Created by nelson on 11/17/16. + * Class used to encapsulate the thread where the WebSocket does the requests. + * */ public class WebsocketWorkerThread extends Thread { private final String TAG = this.getClass().getName(); @@ -27,6 +28,11 @@ public class WebsocketWorkerThread extends Thread { private WebSocket mWebSocket; private NodeErrorListener mErrorListener; + /** + * Constructor + * + * @param url URL of the WebSocket + */ public WebsocketWorkerThread(String url){ try { WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(TIMEOUT); @@ -49,9 +55,12 @@ public class WebsocketWorkerThread extends Thread { } /** - * Constructor with connection error listener - * @param url - * @param errorListener + * Constructor with connection error listener. + * + * @param url URL of the WebSocket + * @param errorListener a class implementing the NodeErrorListener interface. This + * should be implemented by the party interested in being notified + * about the failure of the connection. */ public WebsocketWorkerThread(String url, NodeErrorListener errorListener){ try { @@ -75,6 +84,9 @@ public class WebsocketWorkerThread extends Thread { } } + /** + * Method call when the thread is started. + */ @Override public void run() { try { @@ -85,6 +97,13 @@ public class WebsocketWorkerThread extends Thread { } } + /** + * Add a WebSocketListener to the thread that will run. This should be implemented by the party + * interested in being notified about the response value of a request. + * + * @param listener listener implemented to be notified when the socket get a response from the + * node + */ public void addListener(WebSocketListener listener){ mWebSocket.addListener(listener); }