Class NetworkTransport

java.lang.Object
com.codename1.crypto.rpc.NetworkTransport
All Implemented Interfaces:
RpcTransport

public class NetworkTransport extends Object implements RpcTransport

The application's RpcTransport: each request goes through the NetworkManager queue as a ConnectionRequest, waiting with addToQueueAndWait, so a call from the EDT keeps the UI responsive. Headers added with header(String, String) go on every request, which is how a provider's API key is passed.

Not shared with the backend, which has com.codename1.backend.WebRpcTransport instead.

  • Constructor Details

    • NetworkTransport

      public NetworkTransport()
  • Method Details

    • header

      public NetworkTransport header(String name, String value)
      Adds a header sent with every request, for instance an API key.
    • timeout

      public NetworkTransport timeout(int millis)
      The request timeout in milliseconds; 30 seconds by default.
    • 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