Class Service

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.fasterxml.jackson.databind.ObjectMapper objectMapper  
    • Constructor Summary

      Constructors 
      Constructor Description
      Service​(boolean includeRawResponses)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract java.io.InputStream performIO​(java.lang.String payload)  
      <T extends Response>
      T
      send​(Request request, java.lang.Class<T> responseType)
      Perform a synchronous JSON-RPC request.
      <T extends Response>
      java.util.concurrent.CompletableFuture<T>
      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<?>>
      io.reactivex.Flowable<T>
      subscribe​(Request request, java.lang.String unsubscribeMethod, java.lang.Class<T> responseType)
      Subscribe to a stream of notifications.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • objectMapper

        protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • Constructor Detail

      • Service

        public Service​(boolean includeRawResponses)
    • Method Detail

      • performIO

        protected abstract java.io.InputStream performIO​(java.lang.String payload)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • send

        public <T extends Response> T send​(Request request,
                                           java.lang.Class<T> responseType)
                                    throws java.io.IOException
        Description copied from interface: Web3jService
        Perform a synchronous JSON-RPC request.
        Specified by:
        send in interface Web3jService
        Type Parameters:
        T - type of a data item returned by the request
        Parameters:
        request - request to perform
        responseType - 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

        public <T extends Response> java.util.concurrent.CompletableFuture<T> sendAsync​(Request jsonRpc20Request,
                                                                                        java.lang.Class<T> responseType)
        Description copied from interface: Web3jService
        Performs an asynchronous JSON-RPC request.
        Specified by:
        sendAsync in interface Web3jService
        Type Parameters:
        T - type of a data item returned by the request
        Parameters:
        jsonRpc20Request - request to perform
        responseType - 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

        public BatchResponse sendBatch​(BatchRequest batchRequest)
                                throws java.io.IOException
        Description copied from interface: Web3jService
        Perform a synchronous JSON-RPC batch requests.
        Specified by:
        sendBatch in interface Web3jService
        Parameters:
        batchRequest - requests to perform
        Returns:
        deserialized JSON-RPC responses
        Throws:
        java.io.IOException - thrown if failed to perform a batch request
      • sendBatchAsync

        public java.util.concurrent.CompletableFuture<BatchResponse> sendBatchAsync​(BatchRequest batchRequest)
        Description copied from interface: Web3jService
        Performs an asynchronous JSON-RPC batch requests.
        Specified by:
        sendBatchAsync in interface Web3jService
        Parameters:
        batchRequest - batch request to perform
        Returns:
        CompletableFuture that will be completed when a result is returned or if a request has failed
      • subscribe

        public <T extends Notification<?>> io.reactivex.Flowable<T> subscribe​(Request request,
                                                                              java.lang.String unsubscribeMethod,
                                                                              java.lang.Class<T> responseType)
        Description copied from interface: Web3jService
        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.

        Specified by:
        subscribe in interface Web3jService
        Type Parameters:
        T - type of incoming event objects
        Parameters:
        request - JSON-RPC request that will be send to subscribe to a stream of events
        unsubscribeMethod - method that will be called to unsubscribe from a stream of notifications
        responseType - class of incoming events objects in a stream
        Returns:
        a Flowable instance that emits incoming events