Package jrpc.clightning
Class LiteCLightningRPC
- java.lang.Object
-
- jrpc.clightning.LiteCLightningRPC
-
public class LiteCLightningRPC extends java.lang.Object
Lite version of the client, this avoid all the complexity given by the design patter under the hood.In particular this call, give the possibility from the file path to create a proxy, and send message over the unix socket. In addition, this class include only a generic method. If you want to use an interface with all method and Java wrapper object you should use CLightningRPC.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
path
protected CLightningSocket
socket
-
Constructor Summary
Constructors Constructor Description LiteCLightningRPC()
Create a client where the configuration it is taken from a config file.LiteCLightningRPC(java.lang.String path)
Create a client where with a connection with the unix socket at the specified path
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
call(java.lang.String methodName, java.lang.Class<T> type)
Make a JSON RPC 2.0 call over the socket, and unwrap the result in a class of the specified type<T> T
call(java.lang.String methodName, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.Class<T> type)
Make a JSON RPC 2.0 call over the socket, and unwrap the result in a class of the specified typejava.lang.String
getPath()
java.lang.String
rawCall(java.lang.String method)
Low lever call, useful if you want useful another type of JSON decoder, it returns a raw string received from the socket.java.lang.String
rawCall(java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> params)
Low lever call, useful if you want useful another type of JSON decoder, it returns a raw string received from the socket.
-
-
-
Field Detail
-
path
protected java.lang.String path
-
socket
protected CLightningSocket socket
-
-
Constructor Detail
-
LiteCLightningRPC
public LiteCLightningRPC(java.lang.String path)
Create a client where with a connection with the unix socket at the specified path- Parameters:
path
- : String that contains the path where the socket it is located
-
LiteCLightningRPC
public LiteCLightningRPC()
Create a client where the configuration it is taken from a config file. TODO: Give the opportunity to use also the os env.
-
-
Method Detail
-
getPath
public java.lang.String getPath()
-
call
public <T> T call(java.lang.String methodName, java.lang.Class<T> type)
Make a JSON RPC 2.0 call over the socket, and unwrap the result in a class of the specified type- Type Parameters:
T
- : The return type.- Parameters:
methodName
- : The method name to be call.type
- : The type of the object where the response need to be decoded.- Returns:
- An object of the specified type with the content of the response.
-
call
public <T> T call(java.lang.String methodName, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.Class<T> type)
Make a JSON RPC 2.0 call over the socket, and unwrap the result in a class of the specified type- Type Parameters:
T
- : The return type.- Parameters:
methodName
- : The method name to be call.params
- : A map where the parameter for the method call are specified.type
- : The type of the object where the response need to be decoded.- Returns:
- An object of the specified type with the content of the response.
-
rawCall
public java.lang.String rawCall(java.lang.String method) throws java.io.IOException
Low lever call, useful if you want useful another type of JSON decoder, it returns a raw string received from the socket.- Parameters:
method
- : The method name to be call.- Returns:
- Raw String returned from the socket.
- Throws:
java.io.IOException
- In case of error
-
rawCall
public java.lang.String rawCall(java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> params) throws java.io.IOException
Low lever call, useful if you want useful another type of JSON decoder, it returns a raw string received from the socket.- Parameters:
method
- : The method name to be call.params
- : A map where the parameter for the method call are specified.- Returns:
- Raw String returned from the socket.
- Throws:
java.io.IOException
- In case of error
-
-