rpc

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextId

func NextId() uint64

func ReadJsonMessages

func ReadJsonMessages(r io.Reader, sleepDuration time.Duration, emitter chan RpcMessage) error

func ReadJsonMessagesFromFile

func ReadJsonMessagesFromFile(fn string, sleepDuration time.Duration, emitter chan RpcMessage)

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(server *Hub, conn *websocket.Conn) *Connection

func (*Connection) BroadCast

func (c *Connection) BroadCast(m RpcMessage)

func (*Connection) Send

func (c *Connection) Send(m RpcMessage)

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub(writer RpcRequestHandler) *Hub

func (*Hub) HandleWebsocketRequest

func (h *Hub) HandleWebsocketRequest(w http.ResponseWriter, r *http.Request)

func (*Hub) SendMessage

func (h *Hub) SendMessage(m RpcMessage)

type RpcError

type RpcError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RpcMessage

type RpcMessage struct {
	Version string         `json:"version"`
	Method  string         `json:"method"`
	Id      uint64         `json:"id"`
	Params  map[string]any `json:"params"`
	Result  any            `json:"result"`
	Error   RpcError       `json:"error,omitempty"`
}

func MakeCall

func MakeCall(method string, params map[string]any) RpcMessage

func MakeError

func MakeError(code int, msg string) RpcMessage

func MakeNotify

func MakeNotify(method string, params map[string]any) RpcMessage

func MakeResult

func MakeResult(id uint64, result any) RpcMessage

type RpcMessageHandler

type RpcMessageHandler interface {
	HandleMessage(m RpcMessage) error
}

type RpcParams

type RpcParams map[string]any

type RpcRequest

type RpcRequest struct {
	Msg  RpcMessage
	Conn *Connection
}

type RpcRequestHandler

type RpcRequestHandler interface {
	HandleMessage(m RpcRequest) error
}

type RpcResponse

type RpcResponse struct {
	Msg RpcMessage
}

type RpcSender

type RpcSender struct {
	// contains filtered or unexported fields
}

func NewRpcSender

func NewRpcSender(writer RpcMessageHandler) *RpcSender

func (*RpcSender) Close

func (s *RpcSender) Close()

func (*RpcSender) Dial

func (s *RpcSender) Dial(addr string) error

func (*RpcSender) ReadPump

func (s *RpcSender) ReadPump()

func (*RpcSender) SendMessages

func (s *RpcSender) SendMessages(emitter chan RpcMessage)

Jump to

Keyboard shortcuts

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