Class WebRpcTransport

java.lang.Object
com.codename1.backend.WebRpcTransport
All Implemented Interfaces:
RpcTransport

public final class WebRpcTransport extends Object implements RpcTransport

The backend's RpcTransport: the chain clients of com.codename1.crypto.rpc (EvmRpc, EsploraClient, SolanaRpc) send through a WebClient, so they share its connection pool, timeouts and certificate checks.

WebClient web = new WebClient().setRequestTimeoutMillis(15000);
EvmRpc eth = new EvmRpc(new WebRpcTransport(web).header("Authorization", "Bearer " + key), url);

Create one per provider and share it; it holds no state per request.

  • Constructor Details

    • WebRpcTransport

      public WebRpcTransport(WebClient client)
      A transport over a client.
    • WebRpcTransport

      public WebRpcTransport()
      A transport over a client with every default.
  • Method Details

    • header

      public WebRpcTransport header(String name, String value)
      Adds a header sent with every request, for instance an API key. Configure the transport before sharing it between threads.
    • send

      public String send(String method, String url, String contentType, String body) throws IOException
      Description copied from interface: RpcTransport

      Sends one request and answers the response body.

      Parameters
      • method: GET or POST
      • url: the full URL
      • contentType: the body's media type, or null for a request without one
      • body: the body, or null
      Throws
      • RpcException: for a status outside 2xx, with the status and the body the server sent
      • IOException: when the request could not be made at all
      Specified by:
      send in interface RpcTransport
      Throws:
      IOException