wsrpc

package
v0.64.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	WsCloseRequestTimeout  = 60 * time.Second
	WsCloseResponseTimeout = 3600 * time.Second
)

Variables

This section is empty.

Functions

func NewService

func NewService(rcvr any) (*service, error)

Types

type RpcRequest

type RpcRequest struct {
	Id            uint64 `json:"id"`
	ServiceMethod string `json:"method"`
	Params        any    `json:"params"`
}

type RpcResponse

type RpcResponse struct {
	Id     uint64 `json:"id"`
	Result any    `json:"result"`
	Error  any    `json:"error"`
}

type WsRpcClient

type WsRpcClient struct {
	Terminated chan bool
	// contains filtered or unexported fields
}

func NewWsRpcClient

func NewWsRpcClient(conn *websocket.Conn, debug bool) *WsRpcClient

func (*WsRpcClient) Call

func (client *WsRpcClient) Call(serviceMethod string, args any, reply any) error

func (*WsRpcClient) Close

func (client *WsRpcClient) Close() error

type WsRpcServer

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

func NewWsRpcServer

func NewWsRpcServer(conn *websocket.Conn, debug bool) *WsRpcServer

func (*WsRpcServer) GetServices

func (server *WsRpcServer) GetServices() []string

func (*WsRpcServer) Listen

func (server *WsRpcServer) Listen() error

func (*WsRpcServer) Register

func (server *WsRpcServer) Register(rcvr any) error

Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:

  • exported method of exported type
  • two arguments, both of exported type
  • the second argument is a pointer
  • one return value, of type error

It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.

func (*WsRpcServer) SetWsConnection

func (server *WsRpcServer) SetWsConnection(conn *websocket.Conn)

Jump to

Keyboard shortcuts

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