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.
|
<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 <T extends Notification<?>> rx.Observable<T> subscribe(Request request, java.lang.String unsubscribeMethod, java.lang.Class<T> responseType)
Web3jService
This method creates an Observable that can be used to subscribe to new notifications. When a client unsubscribes from this Observable 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 stream