jsonrpc

package
v0.0.0-...-7079ce8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version                      = "2.0"
	RSPControllerSubscribeMethod = "subscribe"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceIdParams

type DeviceIdParams struct {
	DeviceId string `json:"device_id"`
}

DeviceIdParams holds the device id parameter used in command requests to RSP Controller

type Message

type Message interface{}

type Notification

type Notification struct {
	Version string     `json:"jsonrpc"`
	Method  string     `json:"method"`
	Params  Parameters `json:"params,omitempty"`
}

Notification represents a JsonRPC 2.0 Notification

func (*Notification) GetParam

func (n *Notification) GetParam(key string, out interface{}) error

GetParam looks for the parameter 'key' and unmarshals it into `out`. If the key is not in the parameters, the Notification has no parameters, or the value cannot be unmarshaled into out, this returns an error.

func (*Notification) SetParam

func (n *Notification) SetParam(key string, v interface{}) error

SetParam sets the value of the parameter 'key' to the marshaled result of v. If 'key' already exists, it's overwritten. If the Notification doesn't have parameters, a new set is created for it.

type Parameters

type Parameters map[string]json.RawMessage

func (Parameters) Get

func (p Parameters) Get(key string, out interface{}) error

Get unmarshals the parameter 'key' into out. Returns an error if the key doesn't exist or fails to unmarshal into out.

func (Parameters) Set

func (p Parameters) Set(key string, v interface{}) error

Sets the value of the parameter 'key' to the marshaled value of v. If the key exists, it's overwritten. If it fails to marshal, this returns an error.

type RSPCommandRequest

type RSPCommandRequest struct {
	Request                // embed
	Params  DeviceIdParams `json:"params"`
}

func NewRSPCommandRequest

func NewRSPCommandRequest(method string, deviceId string) RSPCommandRequest

type RSPControllerSubscribeRequest

type RSPControllerSubscribeRequest struct {
	Request          // embed
	Params  []string `json:"params"`
}

func NewRSPControllerSubscribeRequest

func NewRSPControllerSubscribeRequest(topics []string) RSPControllerSubscribeRequest

type Request

type Request struct {
	Version string          `json:"jsonrpc"`
	Id      string          `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
}

Request represents a JsonRPC 2.0 Request

func NewRequest

func NewRequest(method string) Request

type Response

type Response struct {
	Version string          `json:"jsonrpc"`
	Id      string          `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   json.RawMessage `json:"error"`
}

Response represents a JsonRPC 2.0 Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL