Documentation ¶
Overview ¶
Package stratumrpc implements a JSON-RPC Stratum ClientCodec and ServerCodec for the rpc2 package.
Beside struct types, StratumCodec allows using positional arguments. Use []interface{} as the type of argument when sending and receiving methods.
Positional arguments example:
server.Handle("add", func(client *rpc2.Client, args []interface{}, result *float64) error { *result = args[0].(float64) + args[1].(float64) return nil }) var result float64 client.Call("add", []interface{}{1, 2}, &result)
Index ¶
Constants ¶
View Source
const (
MethodNotification = ""
)
Variables ¶
This section is empty.
Functions ¶
func NewJsonRpc2Codec ¶
func NewJsonRpc2Codec(conn io.ReadWriteCloser) rpc2.Codec
NewJsonRpc2Codec returns a new rpc2.Codec using JSON-RPC 2.0 on conn.
Types ¶
type JsonRpcError ¶
type JsonRpcError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
Error represent JSON-RPC 2.0 "Error object".
func NewError ¶
func NewError(code int, message string) JsonRpcError
NewError returns an Error with given code and message.
func (JsonRpcError) Error ¶
func (e JsonRpcError) Error() string
Error returns JSON representation of Error.
Click to show internal directories.
Click to hide internal directories.