Class WebRpcTransport
java.lang.Object
com.codename1.backend.WebRpcTransport
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionA transport over a client with every default.WebRpcTransport(WebClient client) A transport over a client. -
Method Summary
-
Constructor Details
-
WebRpcTransport
A transport over a client. -
WebRpcTransport
public WebRpcTransport()A transport over a client with every default.
-
-
Method Details
-
header
Adds a header sent with every request, for instance an API key. Configure the transport before sharing it between threads. -
send
Description copied from interface:RpcTransportSends one request and answers the response body.
Parameters
method:GETorPOSTurl: the full URLcontentType: the body's media type, ornullfor a request without onebody: the body, ornull
Throws
RpcException: for a status outside 2xx, with the status and the body the server sentIOException: when the request could not be made at all
- Specified by:
sendin interfaceRpcTransport- Throws:
IOException
-