Documentation ¶
Overview ¶
Package JSONRPC provides methods for working with JSONRPC object instances.
Index ¶
- type Advanced
- type Any
- type ErrorCode
- type Instance
- func (self Instance) AsJSONRPC() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) MakeNotification(method string, params any) Notification
- func (self Instance) MakeRequest(method string, params any, id any) Request
- func (self Instance) MakeResponse(result any, id any) Response
- func (self Instance) MakeResponseError(code int, message string) ResponseError
- func (self Instance) ProcessAction(action any) any
- func (self Instance) ProcessString(action string) string
- func (self Instance) SetScope(scope string, target Object.Instance)
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
- type Notification
- type Request
- type Response
- type ResponseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type ErrorCode ¶
type ErrorCode = gdclass.JSONRPCErrorCode //gd:JSONRPC.ErrorCode
const ( /*The request could not be parsed as it was not valid by JSON standard ([method JSON.parse] failed).*/ ParseError ErrorCode = -32700 /*A method call was requested but the request's format is not valid.*/ InvalidRequest ErrorCode = -32600 /*A method call was requested but no function of that name existed in the JSONRPC subclass.*/ MethodNotFound ErrorCode = -32601 /*A method call was requested but the given method parameters are not valid. Not used by the built-in JSONRPC.*/ InvalidParams ErrorCode = -32602 /*An internal error occurred while processing the request. Not used by the built-in JSONRPC.*/ InternalError ErrorCode = -32603 )
type Instance ¶
[url=https://www.jsonrpc.org/]JSON-RPC[/url] is a standard which wraps a method call in a [JSON] object. The object has a particular structure and identifies which method is called, the parameters to that function, and carries an ID to keep track of responses. This class implements that standard on top of [Dictionary]; you will have to convert between a [Dictionary] and [JSON] with other functions.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) MakeNotification ¶
func (self Instance) MakeNotification(method string, params any) Notification
Returns a dictionary in the form of a JSON-RPC notification. Notifications are one-shot messages which do not expect a response. - [param method]: Name of the method being called. - [param params]: An array or dictionary of parameters being passed to the method.
func (Instance) MakeRequest ¶
Returns a dictionary in the form of a JSON-RPC request. Requests are sent to a server with the expectation of a response. The ID field is used for the server to specify which exact request it is responding to. - [param method]: Name of the method being called. - [param params]: An array or dictionary of parameters being passed to the method. - [param id]: Uniquely identifies this request. The server is expected to send a response with the same ID.
func (Instance) MakeResponse ¶
When a server has received and processed a request, it is expected to send a response. If you did not want a response then you need to have sent a Notification instead. - [param result]: The return value of the function which was called. - [param id]: The ID of the request this response is targeted to.
func (Instance) MakeResponseError ¶
func (self Instance) MakeResponseError(code int, message string) ResponseError
Creates a response which indicates a previous reply has failed in some way. - [param code]: The error code corresponding to what kind of error this is. See the [enum ErrorCode] constants. - [param message]: A custom message about this error. - [param id]: The request this error is a response to.
func (Instance) ProcessAction ¶
Given a Dictionary which takes the form of a JSON-RPC request: unpack the request and run it. Methods are resolved by looking at the field called "method" and looking for an equivalently named function in the JSONRPC object. If one is found that method is called. To add new supported methods extend the JSONRPC class and call [method process_action] on your subclass. [param action]: The action to be run, as a Dictionary in the form of a JSON-RPC request or notification.
func (Instance) ProcessString ¶
func (*Instance) UnsafePointer ¶
type Notification ¶
type Notification struct { Method string `gd:"method"` Params interface{} `gd:"params"` }