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 ¶
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 ¶
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.