public abstract class Service extends java.lang.Object implements Web3jService
Modifier and Type | Field and Description |
---|---|
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
Constructor and Description |
---|
Service(boolean includeRawResponses) |
Modifier and Type | Method and Description |
---|---|
protected abstract java.io.InputStream |
performIO(java.lang.String payload) |
<T extends Response> |
send(Request request,
java.lang.Class<T> responseType)
Perform a synchronous JSON-RPC request.
|
<T extends Response> |
sendAsync(Request jsonRpc20Request,
java.lang.Class<T> responseType)
Performs an asynchronous JSON-RPC request.
|
BatchResponse |
sendBatch(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<?>> |
subscribe(Request request,
java.lang.String unsubscribeMethod,
java.lang.Class<T> responseType)
Subscribe to a stream of notifications.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
protected abstract java.io.InputStream performIO(java.lang.String payload) throws java.io.IOException
java.io.IOException
public <T extends Response> T send(Request request, java.lang.Class<T> responseType) throws java.io.IOException
Web3jService
send
in interface Web3jService
T
- type of a data item returned by the requestrequest
- request to performresponseType
- class of a data item returned by the requestjava.io.IOException
- thrown if failed to perform a requestpublic <T extends Response> java.util.concurrent.CompletableFuture<T> sendAsync(Request jsonRpc20Request, java.lang.Class<T> responseType)
Web3jService
sendAsync
in interface Web3jService
T
- type of a data item returned by the requestjsonRpc20Request
- request to performresponseType
- class of a data item returned by the requestpublic BatchResponse sendBatch(BatchRequest batchRequest) throws java.io.IOException
Web3jService
sendBatch
in interface Web3jService
batchRequest
- requests to performjava.io.IOException
- thrown if failed to perform a batch requestpublic java.util.concurrent.CompletableFuture<BatchResponse> sendBatchAsync(BatchRequest batchRequest)
Web3jService
sendBatchAsync
in interface Web3jService
batchRequest
- batch request to performpublic <T extends Notification<?>> io.reactivex.Flowable<T> subscribe(Request request, java.lang.String unsubscribeMethod, java.lang.Class<T> responseType)
Web3jService
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.
subscribe
in interface Web3jService
T
- type of incoming event objectsrequest
- 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 streamFlowable
instance that emits incoming events