rpc

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RPCFunctions = struct {
	sync.RWMutex
	m RPCMap
}{/* contains filtered or unexported fields */}

RPCFunctions stores the mapping of function names to function calls.

Functions

func HandleWebSocket

func HandleWebSocket(ctx context.Context, w http.ResponseWriter, r *http.Request)

HandleWebSocket handles incoming WebSocket connections.

It upgrades the HTTP connection to the WebSocket protocol, reads JSON-RPC requests from the client, unmarshals the requests, calls the corresponding function, and sends the response back to the client.

func MarshalData added in v1.1.0

func MarshalData(data interface{}) ([]byte, error)

MarshalData encodes data into the specified format (either "json" or "msgpack").

func On added in v1.1.0

func On(name string, callback func(conn *wsconn.ConnectionWrapper, data interface{}))

On registers a callback function that will be executed when called via RPC.

func UnmarshalData added in v1.1.1

func UnmarshalData(data []byte, dest interface{}) error

UnmarshalData decodes data into the specified format (either "json" or "msgpack").

Types

type RPCMap

type RPCMap map[string]func(*wsconn.ConnectionWrapper, interface{}) error

RPCMap defines the structure for function mappings.

Jump to

Keyboard shortcuts

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