websocket

package
v0.0.0-...-d77a897 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequestIDLength size of id sent on WS request
	RequestIDLength = 16
	// CloseMessageCode identifier the message id for a close request
	CloseMessageCode = 1000
	// DefaultTimeout timeout in seconds
	DefaultTimeout = 30
)

Variables

View Source
var (
	ErrIDInUse           = errors.New("id already in use")
	ErrTimeout           = errors.New("timeout")
	ErrInvalidResponseID = errors.New("invalid response id")
)

Functions

This section is empty.

Types

type Option

type Option func(ws *WebSocket) error

type RPCError

type RPCError struct {
	Code    int    `json:"code" msgpack:"code"`
	Message string `json:"message,omitempty" msgpack:"message,omitempty"`
}

RPCError represents a JSON-RPC error

func (*RPCError) Error

func (r *RPCError) Error() string

type RPCNotification

type RPCNotification struct {
	ID     interface{}   `json:"id" msgpack:"id"`
	Method string        `json:"method,omitempty" msgpack:"method,omitempty"`
	Params []interface{} `json:"params,omitempty" msgpack:"params,omitempty"`
}

RPCNotification represents an outgoing JSON-RPC notification

type RPCRequest

type RPCRequest struct {
	ID     interface{}   `json:"id" msgpack:"id"`
	Async  bool          `json:"async,omitempty" msgpack:"async,omitempty"`
	Method string        `json:"method,omitempty" msgpack:"method,omitempty"`
	Params []interface{} `json:"params,omitempty" msgpack:"params,omitempty"`
}

RPCRequest represents an incoming JSON-RPC request

type RPCResponse

type RPCResponse struct {
	ID     interface{} `json:"id" msgpack:"id"`
	Error  *RPCError   `json:"error,omitempty" msgpack:"error,omitempty"`
	Result interface{} `json:"result,omitempty" msgpack:"result,omitempty"`
}

RPCResponse represents an outgoing JSON-RPC response

type WebSocket

type WebSocket struct {
	Conn *websocket.Conn

	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewWebsocketWithOptions

func NewWebsocketWithOptions(url string, options ...Option) (*WebSocket, error)

func (*WebSocket) Close

func (ws *WebSocket) Close() error

func (*WebSocket) Send

func (ws *WebSocket) Send(method string, params []interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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