summaryrefslogtreecommitdiff
path: root/doc/classes/JSONRPC.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/JSONRPC.xml')
-rw-r--r--doc/classes/JSONRPC.xml86
1 files changed, 42 insertions, 44 deletions
diff --git a/doc/classes/JSONRPC.xml b/doc/classes/JSONRPC.xml
index 1e74159f58..8f1d1581b1 100644
--- a/doc/classes/JSONRPC.xml
+++ b/doc/classes/JSONRPC.xml
@@ -1,81 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="JSONRPC" inherits="Object" version="4.0">
<brief_description>
+ A helper to handle dictionaries which look like JSONRPC documents.
</brief_description>
<description>
+ [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.
</description>
<tutorials>
</tutorials>
<methods>
<method name="make_notification">
- <return type="Dictionary">
- </return>
- <argument index="0" name="method" type="String">
- </argument>
- <argument index="1" name="params" type="Variant">
- </argument>
+ <return type="Dictionary" />
+ <argument index="0" name="method" type="String" />
+ <argument index="1" name="params" type="Variant" />
<description>
+ Returns a dictionary in the form of a JSON-RPC notification. Notifications are one-shot messages which do not expect a response.
+ - [code]method[/code]: Name of the method being called.
+ - [code]params[/code]: An array or dictionary of parameters being passed to the method.
</description>
</method>
<method name="make_request">
- <return type="Dictionary">
- </return>
- <argument index="0" name="method" type="String">
- </argument>
- <argument index="1" name="params" type="Variant">
- </argument>
- <argument index="2" name="id" type="Variant">
- </argument>
+ <return type="Dictionary" />
+ <argument index="0" name="method" type="String" />
+ <argument index="1" name="params" type="Variant" />
+ <argument index="2" name="id" type="Variant" />
<description>
+ 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.
+ - [code]method[/code]: Name of the method being called.
+ - [code]params[/code]: An array or dictionary of parameters being passed to the method.
+ - [code]id[/code]: Uniquely identifies this request. The server is expected to send a response with the same ID.
</description>
</method>
<method name="make_response">
- <return type="Dictionary">
- </return>
- <argument index="0" name="result" type="Variant">
- </argument>
- <argument index="1" name="id" type="Variant">
- </argument>
+ <return type="Dictionary" />
+ <argument index="0" name="result" type="Variant" />
+ <argument index="1" name="id" type="Variant" />
<description>
+ 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.
+ - [code]result[/code]: The return value of the function which was called.
+ - [code]id[/code]: The ID of the request this response is targeted to.
</description>
</method>
<method name="make_response_error" qualifiers="const">
- <return type="Dictionary">
- </return>
- <argument index="0" name="code" type="int">
- </argument>
- <argument index="1" name="message" type="String">
- </argument>
- <argument index="2" name="id" type="Variant" default="null">
- </argument>
+ <return type="Dictionary" />
+ <argument index="0" name="code" type="int" />
+ <argument index="1" name="message" type="String" />
+ <argument index="2" name="id" type="Variant" default="null" />
<description>
+ Creates a response which indicates a previous reply has failed in some way.
+ - [code]code[/code]: The error code corresponding to what kind of error this is. See the [enum ErrorCode] constants.
+ - [code]message[/code]: A custom message about this error.
+ - [code]id[/code]: The request this error is a response to.
</description>
</method>
<method name="process_action">
- <return type="Variant">
- </return>
- <argument index="0" name="action" type="Variant">
- </argument>
- <argument index="1" name="recurse" type="bool" default="false">
- </argument>
+ <return type="Variant" />
+ <argument index="0" name="action" type="Variant" />
+ <argument index="1" name="recurse" type="bool" default="false" />
<description>
+ 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.
+ [code]action[/code]: The action to be run, as a Dictionary in the form of a JSON-RPC request or notification.
</description>
</method>
<method name="process_string">
- <return type="String">
- </return>
- <argument index="0" name="action" type="String">
- </argument>
+ <return type="String" />
+ <argument index="0" name="action" type="String" />
<description>
</description>
</method>
<method name="set_scope">
- <return type="void">
- </return>
- <argument index="0" name="scope" type="String">
- </argument>
- <argument index="1" name="target" type="Object">
- </argument>
+ <return type="void" />
+ <argument index="0" name="scope" type="String" />
+ <argument index="1" name="target" type="Object" />
<description>
</description>
</method>
@@ -86,6 +83,7 @@
<constant name="INVALID_REQUEST" value="-32600" enum="ErrorCode">
</constant>
<constant name="METHOD_NOT_FOUND" value="-32601" enum="ErrorCode">
+ A method call was requested but no function of that name existed in the JSONRPC subclass.
</constant>
<constant name="INVALID_PARAMS" value="-32602" enum="ErrorCode">
</constant>