Package org.web3j.protocol
Interface Web3jService
-
- All Known Implementing Classes:
HttpService,IpcService,Service,UnixIpcService,WebSocketService,WindowsIpcService
public interface Web3jServiceServices API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes resources used by the service.<T extends Response>
Tsend(Request request, java.lang.Class<T> responseType)Perform a synchronous JSON-RPC request.<T extends Response>
java.util.concurrent.CompletableFuture<T>sendAsync(Request request, java.lang.Class<T> responseType)Performs an asynchronous JSON-RPC request.BatchResponsesendBatch(BatchRequest batchRequest)Perform a synchronous JSON-RPC batch requests.java.util.concurrent.CompletableFuture<BatchResponse>sendBatchAsync(BatchRequest batchRequest)Performs an asynchronous JSON-RPC batch requests.<T extends Notification<?>>
io.reactivex.Flowable<T>subscribe(Request request, java.lang.String unsubscribeMethod, java.lang.Class<T> responseType)Subscribe to a stream of notifications.
-
-
-
Method Detail
-
send
<T extends Response> T send(Request request, java.lang.Class<T> responseType) throws java.io.IOException
Perform a synchronous JSON-RPC request.- Type Parameters:
T- type of a data item returned by the request- Parameters:
request- request to performresponseType- class of a data item returned by the request- Returns:
- deserialized JSON-RPC response
- Throws:
java.io.IOException- thrown if failed to perform a request
-
sendAsync
<T extends Response> java.util.concurrent.CompletableFuture<T> sendAsync(Request request, java.lang.Class<T> responseType)
Performs an asynchronous JSON-RPC request.- Type Parameters:
T- type of a data item returned by the request- Parameters:
request- request to performresponseType- class of a data item returned by the request- Returns:
- CompletableFuture that will be completed when a result is returned or if a request has failed
-
sendBatch
BatchResponse sendBatch(BatchRequest batchRequest) throws java.io.IOException
Perform a synchronous JSON-RPC batch requests.- Parameters:
batchRequest- requests to perform- Returns:
- deserialized JSON-RPC responses
- Throws:
java.io.IOException- thrown if failed to perform a batch request
-
sendBatchAsync
java.util.concurrent.CompletableFuture<BatchResponse> sendBatchAsync(BatchRequest batchRequest)
Performs an asynchronous JSON-RPC batch requests.- Parameters:
batchRequest- batch request to perform- Returns:
- CompletableFuture that will be completed when a result is returned or if a request has failed
-
subscribe
<T extends Notification<?>> io.reactivex.Flowable<T> subscribe(Request request, java.lang.String unsubscribeMethod, java.lang.Class<T> responseType)
Subscribe to a stream of notifications. A stream of notifications is opened by by performing a specified JSON-RPC request and is closed by calling the unsubscribe method. Different WebSocket implementations use different pair of subscribe/unsubscribe methods.This method creates an Flowable that can be used to subscribe to new notifications. When a client unsubscribes from this Flowable the service unsubscribes from the underlying stream of events.
- Type Parameters:
T- type of incoming event objects- Parameters:
request- JSON-RPC request that will be send to subscribe to a stream of eventsunsubscribeMethod- method that will be called to unsubscribe from a stream of notificationsresponseType- class of incoming events objects in a stream- Returns:
- a
Flowableinstance that emits incoming events
-
close
void close() throws java.io.IOExceptionCloses resources used by the service.- Throws:
java.io.IOException- thrown if a service failed to close all resources
-
-