Class JSONRPC2Session


  • public class JSONRPC2Session
    extends Object
    Sends requests and / or notifications to a specified JSON-RPC 2.0 server URL. The JSON-RPC 2.0 messages are dispatched by means of HTTP(S) POST. This class is thread-safe.
    Author:
    Vladimir Dzhuvinov, Mike Outland
    • Field Detail

      • JSON_MEDIA_TYPE

        public static final okhttp3.MediaType JSON_MEDIA_TYPE
    • Constructor Detail

      • JSONRPC2Session

        public JSONRPC2Session​(URL url)
    • Method Detail

      • getURL

        public URL getURL()
        Gets the JSON-RPC 2.0 server URL.
        Returns:
        The server URL.
      • setURL

        public void setURL​(URL url)
        Sets the JSON-RPC 2.0 server URL.
        Parameters:
        url - The server URL. Must not be null.
      • send

        public JSONRPC2Response send​(JSONRPC2Request request)
                              throws JSONRPC2SessionException
        Sends a JSON-RPC 2.0 request using HTTP POST and returns the server response.
        Parameters:
        request - The JSON-RPC 2.0 request to send. Must not be null.
        Returns:
        The JSON-RPC 2.0 response returned by the server.
        Throws:
        JSONRPC2SessionException - On a network error, unexpected HTTP response content type or invalid JSON-RPC 2.0 response.