Package org.starcoin.jsonrpc.client
Class JSONRPC2Session
- java.lang.Object
-
- org.starcoin.jsonrpc.client.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 Summary
Fields Modifier and Type Field Description static okhttp3.MediaTypeJSON_MEDIA_TYPE
-
Constructor Summary
Constructors Constructor Description JSONRPC2Session(URL url)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLgetURL()Gets the JSON-RPC 2.0 server URL.JSONRPC2Responsesend(JSONRPC2Request request)Sends a JSON-RPC 2.0 request using HTTP POST and returns the server response.voidsetURL(URL url)Sets the JSON-RPC 2.0 server URL.
-
-
-
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 benull.
-
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 benull.- 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.
-
-