Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public interface RpcTransport
Known subtypesNetworkTransport
The one HTTP exchange every chain client needs: send a body, read the reply. The clients in
this package are written against this interface alone, so the same EvmRpc,
EsploraClient and SolanaRpc run in an application and on the backend:
- in an application,
NetworkTransportsends through theNetworkManager; - on the backend,
com.codename1.backend.WebRpcTransportsends through itsWebClient.
A test passes its own implementation that answers recorded replies.
Every call blocks until the reply arrives. On the EDT the application transport waits with
invokeAndBlock, as NetworkManager.addToQueueAndWait does, so the UI keeps painting.
Methods
public abstract String send(String method, String url, String contentType, String body)
throws IOException | Sends one request and answers the response body. |
Method details
send
public abstract String send(String method, String url, String contentType, String body)
throws IOExceptionSends one request and answers the response body.
Parameters
methodStringGETorPOSTurlString- the full URL
contentTypeString- the body’s media type, or
nullfor a request without one bodyString- 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