public class Client extends Publisher<Client.events> implements TransportEventHandler
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
Client.events<T> |
static interface |
Client.OnChainsqlSubRet |
static interface |
Client.OnConnected |
static interface |
Client.OnContractEvent |
static interface |
Client.OnDisconnected |
static interface |
Client.OnLedgerClosed |
static interface |
Client.OnMessage |
static interface |
Client.OnPathFind |
static interface |
Client.OnReconnected |
static interface |
Client.OnReconnecting |
static interface |
Client.OnSendMessage |
static interface |
Client.OnStateChange |
static interface |
Client.OnSubscribed |
static interface |
Client.OnTBMessage |
static interface |
Client.OnTXMessage |
static interface |
Client.OnValidatedTransaction |
static class |
Client.ThrowingRunnable |
Publisher.Callback<T>, Publisher.ErrBack<T>| 限定符和类型 | 字段和说明 |
|---|---|
protected Thread |
clientThread
|
boolean |
connected |
static Logger |
logger |
long |
maintenanceSchedule |
String |
NAMEINDB |
double |
randomBugsFrequency
When this is non 0, we randomly disconnect when trying to send messages
See
sendMessage(org.json.JSONObject) |
protected TreeMap<Integer,Request> |
requests |
String |
schemaID |
int |
SEQUENCE |
ServerInfo |
serverInfo |
protected ScheduledExecutorService |
service |
SubscriptionManager |
subscriptions |
| 构造器和说明 |
|---|
Client(WebSocketTransport ws)
Constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
Account |
accountFromSeed(String masterSeed)
Request account information.
|
org.json.JSONObject |
accountInfo(AccountID account)
Request for account information.
|
AccountTxPager |
accountTxPager(AccountID accountID)
Request account transaction page.
|
Client |
connect(String uri)
After calling this method, all subsequent interaction with the api should
be called via posting Runnable() run blocks to the Executor.
|
void |
connect(String s,
Client.OnConnected onConnected)
Handler binders binder
|
Client |
connect(String uri,
String serverCertPath,
String storePass) |
org.json.JSONObject |
contractCall(org.json.JSONObject obj)
contractCall synchronously
|
void |
contractCall(org.json.JSONObject obj,
Publisher.Callback<org.json.JSONObject> cb)
contractCall asynchronously
|
void |
disconnect()
Disconnect from websocket-url
|
void |
disconnect(Client.OnDisconnected onDisconnected)
Disconnect from current connection.
|
void |
dispose()
Release websocket connection.
|
void |
doConnect(String uri)
Connect.
|
void |
doConnect(String uri,
String serverCertPath,
String storePass) |
void |
GetAccountLines(AccountID addy,
Publisher.Callback<org.json.JSONObject> cb)
Request for account_lines.
|
org.json.JSONObject |
GetAccountLines(String address)
GetAccountLines synchronously
|
org.json.JSONObject |
getAccountTables(String address,
boolean bGetDetail) |
void |
getAccountTables(String address,
boolean bGetDetail,
Publisher.Callback<org.json.JSONObject> cb) |
org.json.JSONObject |
getBySqlAdmin(String sql) |
void |
getBySqlAdmin(String sql,
Publisher.Callback<org.json.JSONObject> cb) |
org.json.JSONObject |
getBySqlUser(String secret,
String accountID,
String sql) |
void |
getBySqlUser(String secret,
String accountID,
String sql,
Publisher.Callback<org.json.JSONObject> cb) |
void |
getCrossChainTxs(String hash,
int limit,
boolean include,
Publisher.Callback<org.json.JSONObject> cb)
Request for transaction information.
|
org.json.JSONObject |
getLedger(org.json.JSONObject option) |
void |
getLedger(org.json.JSONObject option,
Publisher.Callback<org.json.JSONObject> cb)
Request for ledger data.
|
org.json.JSONObject |
getLedgerTxs(Integer ledgerSeq,
boolean bIncludeSuccess,
boolean bIncludefailure) |
void |
getLedgerTxs(Integer ledgerSeq,
boolean bIncludeSuccess,
boolean bIncludefailure,
Publisher.Callback<org.json.JSONObject> cb) |
org.json.JSONObject |
getLedgerVersion() |
void |
getLedgerVersion(Publisher.Callback<org.json.JSONObject> cb) |
org.json.JSONObject |
getNameInDB(String owner,
String tableName) |
void |
getNameInDB(String owner,
String tableName,
Publisher.Callback<org.json.JSONObject> cb) |
org.json.JSONObject |
getPeers()
Get peers
|
org.json.JSONObject |
getSchemaInfo(String schemaID)
Request for schema_info.
|
org.json.JSONObject |
getSchemaList(org.json.JSONObject params)
Get schema_list
|
org.json.JSONObject |
getServerInfo()
Get server_info
|
org.json.JSONObject |
getTableAuth(String owner,
String tableName,
List<String> accounts) |
void |
getTableAuth(String owner,
String tableName,
List<String> accounts,
Publisher.Callback<org.json.JSONObject> cb) |
org.json.JSONObject |
getTransaction(org.json.JSONObject txInfo)
getTransaction synchronously
|
org.json.JSONObject |
getTransaction(String hash)
getTransaction synchronously
|
void |
getTransaction(String hash,
Publisher.Callback<org.json.JSONObject> cb)
Request for a transaction's information.
|
org.json.JSONObject |
getTransactionCount()
Get transaction count on chain.
|
org.json.JSONObject |
getTransactions(String address,
int limit) |
void |
getTransactions(String address,
int limit,
org.json.JSONObject marker,
Publisher.Callback<org.json.JSONObject> cb)
Request for transaction information.
|
void |
getTransactions(String address,
int limit,
Publisher.Callback<org.json.JSONObject> cb)
Request for transaction information.
|
org.json.JSONObject |
getUnlList()
Get unl_list
|
org.json.JSONObject |
getUserToken(String owner,
String user,
String name)
Get user_token for table,if token got not null, it is a confidential table.
|
void |
getUserToken(String owner,
String user,
String name,
Publisher.Callback<org.json.JSONObject> cb) |
static void |
log(Level level,
String fmt,
Object... args)
Log tools.
|
<T> Request |
makeManagedRequest(Command cmd,
Request.Manager<T> manager,
Request.Builder<T> builder)
Managed Requests API
|
Request |
newRequest(Command cmd)
Create a new request.
|
void |
nextTickOrWhenConnected(Client.OnConnected onConnected)
Trigger next tick or when connected.
|
void |
nowOrWhenConnected(Client.OnConnected onConnected)
Now or when connected trigger.
|
void |
onConnected()
Run when connected.
|
Client |
onConnected(Client.OnConnected onConnected)
Trigger when websocket connection succeed.
|
void |
onConnecting(int attempt)
Override method,default.
|
Client |
onContractEvent(Client.OnContractEvent cb) |
void |
onDisconnected(boolean willReconnect)
Run when disconnected.
|
Client |
onDisconnected(Client.OnDisconnected cb)
Trigger when websocket connection disconnected.
|
void |
onError(Exception error)
Override method,default.
|
protected void |
onException(Exception e) |
Client |
onLedgerClosed(Client.OnLedgerClosed cb)
Trigger when ledger closed
|
Client |
OnMessage(Client.OnMessage cb)
Trigger when websocket message received.
|
void |
onMessage(org.json.JSONObject msg)
This is to ensure we run everything on
clientThread |
void |
onMessageInClientThread(org.json.JSONObject msg)
Client message thread.
|
Client |
onReconnected(Client.OnReconnected cb)
Trigger when reconnect to a server succeed.
|
Client |
onReconnecting(Client.OnReconnecting cb)
Trigger when reconnecting to a server begins.
|
Client |
OnSubChainsqlRet(Client.OnChainsqlSubRet cb) |
Client |
OnTBMessage(Client.OnTBMessage cb)
Trigger when transaction related to a subscribed table validate_success or db_success.
|
void |
onTransactionResult(TransactionResult tr)
Transaction returned.
|
Client |
OnTXMessage(Client.OnTXMessage cb)
Trigger when a subscribed transaction validate_success or db_success.
|
Client |
onValidatedTransaction(Client.OnValidatedTransaction cb)
Trigger when a transaction validated.
|
static org.json.JSONObject |
parseJSON(String s)
JSON String to JSONObject.
|
Request |
ping()
Request ping.
|
protected void |
prepareExecutor() |
static String |
prettyJSON(org.json.JSONObject object)
JSON object to String.
|
void |
reconnect()
Reconnect when disconnected.
|
Request |
requestBookOffers(Issue get,
Issue pay)
Request for book offers.
|
void |
requestBookOffers(Number ledger_index,
Issue get,
Issue pay,
Request.Manager<ArrayList<Offer>> cb)
Request for book_offers.
|
void |
requestLedgerEntry(Hash256 index,
Number ledger_index,
Request.Manager<LedgerEntry> cb)
Request for a ledger_entry.
|
void |
resubscribeStreams() |
void |
run(Runnable runnable)
Run a task.
|
void |
schedule(long ms,
Runnable runnable)
Start a scheduled task.
|
org.json.JSONObject |
select(String secret,
AccountID account,
AccountID owner,
String name,
String raw,
Publisher.Callback<org.json.JSONObject> cb)
Select data from chain.
|
void |
sendRequest(Request request)
Send a request message.
|
static void |
shutdown() |
Request |
submit(String tx_blob,
boolean fail_hard)
Submit a transaction
|
void |
subscribe(org.json.JSONObject subscription) |
Request |
subscribeAccount(AccountID... accounts)
Subscribe for account.
|
Request |
subscribeBookOffers(Issue get,
Issue pay)
Request for book-offers.
|
org.json.JSONObject |
tablePrepare(org.json.JSONObject txjson)
Prepare for a transaction for : filling in NameInDB field, filling in CheckHash field for StrictMode
|
Client |
transactionSubscriptionManager(TransactionSubscriptionManager transactionSubscriptionManager) |
void |
unsubscribe(org.json.JSONObject subscription) |
Request |
unsubscribeAccount(AccountID... accounts) |
void |
unsubscribeStreams() |
void |
whenConnected(boolean nextTick,
Client.OnConnected onConnected)
Trigger when connected.
|
clearAllListeners, emit, execute, on, on, once, once, removeListenerpublic static final Logger logger
public double randomBugsFrequency
sendMessage(org.json.JSONObject)protected ScheduledExecutorService service
protected Thread clientThread
public long maintenanceSchedule
public int SEQUENCE
public String NAMEINDB
public boolean connected
public ServerInfo serverInfo
public SubscriptionManager subscriptions
public String schemaID
public Client(WebSocketTransport ws)
ws - Websocket implementation.public Client onValidatedTransaction(Client.OnValidatedTransaction cb)
cb - Callbackpublic Client onLedgerClosed(Client.OnLedgerClosed cb)
cb - Callbackpublic Client OnTBMessage(Client.OnTBMessage cb)
cb - Callbackpublic Client OnSubChainsqlRet(Client.OnChainsqlSubRet cb)
public Client OnTXMessage(Client.OnTXMessage cb)
cb - Callbackpublic Client OnMessage(Client.OnMessage cb)
cb - Callbackpublic Client onReconnecting(Client.OnReconnecting cb)
cb - Callbackpublic Client onReconnected(Client.OnReconnected cb)
cb - Callbackpublic Client onConnected(Client.OnConnected onConnected)
onConnected - Callbackpublic Client onDisconnected(Client.OnDisconnected cb)
cb - Callback.public Client onContractEvent(Client.OnContractEvent cb)
public static void shutdown()
public Client transactionSubscriptionManager(TransactionSubscriptionManager transactionSubscriptionManager)
transactionSubscriptionManager - Subscribe manager.public static void log(Level level, String fmt, Object... args)
level - Log level.fmt - Format.args - Args.public static String prettyJSON(org.json.JSONObject object)
object - JSONObject.public static org.json.JSONObject parseJSON(String s)
s - JSON String.public Client connect(String uri)
uri - Websocket uri.onMessage(org.json.JSONObject)public void doConnect(String uri)
uri - Connect uri.public void doConnect(String uri, String serverCertPath, String storePass) throws Exception
Exceptionpublic void disconnect()
public void reconnect()
public void connect(String s, Client.OnConnected onConnected)
s - Url.onConnected - Callback.public void disconnect(Client.OnDisconnected onDisconnected)
onDisconnected - Callback.public void whenConnected(boolean nextTick,
Client.OnConnected onConnected)
nextTick - Next tick trigger callback.onConnected - Callback.public void nowOrWhenConnected(Client.OnConnected onConnected)
onConnected - Callback.public void nextTickOrWhenConnected(Client.OnConnected onConnected)
onConnected - Callback.public void dispose()
public void run(Runnable runnable)
runnable - Thread object.public void schedule(long ms,
Runnable runnable)
ms - Milliseconds.runnable - Runnable object.protected void prepareExecutor()
protected void onException(Exception e)
public void onMessage(org.json.JSONObject msg)
clientThreadonMessage 在接口中 TransportEventHandlerpublic void onConnecting(int attempt)
onConnecting 在接口中 TransportEventHandlerpublic void onError(Exception error)
onError 在接口中 TransportEventHandlerpublic void onDisconnected(boolean willReconnect)
onDisconnected 在接口中 TransportEventHandlerpublic void onConnected()
onConnected 在接口中 TransportEventHandlerpublic void unsubscribeStreams()
public void resubscribeStreams()
public void onMessageInClientThread(org.json.JSONObject msg)
msg - JSONObject msg.public void onTransactionResult(TransactionResult tr)
tr - Result data.public Account accountFromSeed(String masterSeed)
masterSeed - Master seed for account.public void subscribe(org.json.JSONObject subscription)
public void unsubscribe(org.json.JSONObject subscription)
public Request newRequest(Command cmd)
cmd - Command name.public void sendRequest(Request request)
request - Request data.public <T> Request makeManagedRequest(Command cmd, Request.Manager<T> manager, Request.Builder<T> builder)
T - Builder parameter type.cmd - Command.manager - Manager.builder - Builder data.public AccountTxPager accountTxPager(AccountID accountID)
accountID - Account address.public void requestLedgerEntry(Hash256 index, Number ledger_index, Request.Manager<LedgerEntry> cb)
index - Hash.ledger_index - Ledger index.cb - Callback.public void requestBookOffers(Number ledger_index, Issue get, Issue pay, Request.Manager<ArrayList<Offer>> cb)
ledger_index - Ledger's index.get - Get.pay - Pay.cb - Callback.public Request submit(String tx_blob, boolean fail_hard)
tx_blob - Tx_blob signed.fail_hard - Fail_hard.public org.json.JSONObject accountInfo(AccountID account)
account - Account address.public org.json.JSONObject select(String secret, AccountID account, AccountID owner, String name, String raw, Publisher.Callback<org.json.JSONObject> cb)
secret - Account seed.account - Account address.owner - Table owner address.name - Table name.raw - Raw data.cb - Callback function.public void getBySqlUser(String secret, String accountID, String sql, Publisher.Callback<org.json.JSONObject> cb)
public org.json.JSONObject getBySqlAdmin(String sql)
public void getBySqlAdmin(String sql, Publisher.Callback<org.json.JSONObject> cb)
public void getNameInDB(String owner, String tableName, Publisher.Callback<org.json.JSONObject> cb)
public org.json.JSONObject getLedgerTxs(Integer ledgerSeq, boolean bIncludeSuccess, boolean bIncludefailure)
public void getLedgerTxs(Integer ledgerSeq, boolean bIncludeSuccess, boolean bIncludefailure, Publisher.Callback<org.json.JSONObject> cb)
public org.json.JSONObject getLedger(org.json.JSONObject option)
public void getLedger(org.json.JSONObject option,
Publisher.Callback<org.json.JSONObject> cb)
option - Ledger options.cb - Callback.public org.json.JSONObject getTransactions(String address, int limit)
public void getTransactions(String address, int limit, Publisher.Callback<org.json.JSONObject> cb)
address - Account address.limit - Transaction count limit.cb - Callback.public void getTransactions(String address, int limit, org.json.JSONObject marker, Publisher.Callback<org.json.JSONObject> cb)
address - Account address.limit - Transaction count limit.marker - Marker from previous call response.cb - Callback.public void getCrossChainTxs(String hash, int limit, boolean include, Publisher.Callback<org.json.JSONObject> cb)
hash - Tx hash ,if "" it will find first tx on this chain.limit - Transaction count limit.include - If include the transaction that hash point out.cb - Callback.public org.json.JSONObject getLedgerVersion()
public void getLedgerVersion(Publisher.Callback<org.json.JSONObject> cb)
public org.json.JSONObject getTransactionCount()
public org.json.JSONObject getServerInfo()
public org.json.JSONObject getUnlList()
public org.json.JSONObject getUserToken(String owner, String user, String name)
owner - Table's owner/creator.user - Operating account.name - Table name.public void getUserToken(String owner, String user, String name, Publisher.Callback<org.json.JSONObject> cb)
public org.json.JSONObject tablePrepare(org.json.JSONObject txjson)
txjson - tx_json with fields and value a transaction needed.public org.json.JSONObject contractCall(org.json.JSONObject obj)
obj - call parameterspublic org.json.JSONObject GetAccountLines(String address)
address - Address to get trust lines.public org.json.JSONObject getPeers()
public void GetAccountLines(AccountID addy, Publisher.Callback<org.json.JSONObject> cb)
addy - account id.cb - Callback.public org.json.JSONObject getTableAuth(String owner, String tableName, List<String> accounts)
public void getTableAuth(String owner, String tableName, List<String> accounts, Publisher.Callback<org.json.JSONObject> cb)
public org.json.JSONObject getAccountTables(String address, boolean bGetDetail)
public void getAccountTables(String address, boolean bGetDetail, Publisher.Callback<org.json.JSONObject> cb)
public void contractCall(org.json.JSONObject obj,
Publisher.Callback<org.json.JSONObject> cb)
obj - call parameterscb - Callback.public org.json.JSONObject getTransaction(String hash)
hash - Transaction hash.public void getTransaction(String hash, Publisher.Callback<org.json.JSONObject> cb)
hash - Transaction hash.cb - Callback.public org.json.JSONObject getTransaction(org.json.JSONObject txInfo)
txInfo - tx information.public Request ping()
public Request subscribeAccount(AccountID... accounts)
accounts - Account addresses.public Request subscribeBookOffers(Issue get, Issue pay)
get - Get.pay - Pay.public Request requestBookOffers(Issue get, Issue pay)
get - Get.pay - Pay.public org.json.JSONObject getSchemaList(org.json.JSONObject params)
public org.json.JSONObject getSchemaInfo(String schemaID)
schemaID - schemaID.Copyright © 2021. All rights reserved.