rpc

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package rpc implements the WebSocket RPC server for gofel.

Package rpc implements the WebSocket RPC server for gofel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleWebSocket

func HandleWebSocket(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 RegisterFunction

func RegisterFunction(name string, function func(*websocket.Conn, interface{}) error)

RegisterFunction allows users to register functions that can be called via RPC

RegisterFunction allows users to register functions that can be called via RPC. It takes two parameters, a string name, and a function that can be called via RPC. The function takes two parameters, a *websocket.Conn and an interface{}.

If the RPCFunctions variable is nil, it is initialized as a new RPCMap. The function is then added to the RPCMap under the key specified by the name parameter.

Types

type RPCMap

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

RPCMap type defines the structure for function mappings

RPCMap is a map of function names to functions that can be called via RPC

var RPCFunctions RPCMap

RPCFunctions stores the mapping of function names to function calls

RPCFunctions is a variable that holds the mapping of function names to functions that can be called via RPC. It is a RPCMap type.

Jump to

Keyboard shortcuts

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