Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RPCClient ¶
type RPCClient interface { CloseConnection() RequestAsync(method string, params ...interface{}) error Dispatch(request *RPCRequest) error ScanConnectionAsync() <-chan []byte UnMarshalResponse(byteData []byte) *RPCResponse }
type RPCError ¶
type RPCRequest ¶
type RPCRequest struct { Method string `json:"method"` Params interface{} `json:"params,omitempty"` ID int `json:"id"` JSONRPC string `json:"jsonrpc"` }
func NewRequest ¶
func NewRequest(method string, params ...interface{}) *RPCRequest
func NewRequestWithID ¶
func NewRequestWithID(id int, method string, params ...interface{}) *RPCRequest
type RPCResponse ¶
type RPCResponse struct { JSONRPC string `json:"jsonrpc"` Result interface{} `json:"result,omitempty"` Params interface{} `json:"params,omitempty"` Method string `json:"method,omitempty"` Error *RPCError `json:"error,omitempty"` ID int `json:"id"` }
func (*RPCResponse) GetBool ¶
func (RPCResponse *RPCResponse) GetBool() (bool, error)
GetBool converts the rpc response to a bool and returns it.
If result was not a bool an error is returned.
func (*RPCResponse) GetFloat ¶
func (RPCResponse *RPCResponse) GetFloat() (float64, error)
GetFloat converts the rpc response to float64 and returns it.
If result was not an float64 an error is returned.
func (*RPCResponse) GetInt ¶
func (RPCResponse *RPCResponse) GetInt() (int64, error)
GetInt converts the rpc response to an int64 and returns it.
If result was not an integer an error is returned.
func (*RPCResponse) GetObject ¶
func (RPCResponse *RPCResponse) GetObject(toType interface{}) error
GetObject converts the rpc response to an arbitrary type.
The function works as you would expect it from json.Unmarshal()
func (*RPCResponse) GetString ¶
func (RPCResponse *RPCResponse) GetString() (string, error)
GetString converts the rpc response to a string and returns it.
If result was not a string an error is returned.
Click to show internal directories.
Click to hide internal directories.