mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
classref: Sync with current master branch (f87858a8f)
This commit is contained in:
@@ -14,63 +14,106 @@ JSONRPC
|
||||
|
||||
A helper to handle dictionaries which look like JSONRPC documents.
|
||||
|
||||
.. rst-class:: classref-introduction-group
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
`JSON-RPC <https://www.jsonrpc.org/>`__ is a standard which wraps a method call in a :ref:`JSON<class_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 :ref:`Dictionary<class_Dictionary>`; you will have to convert between a :ref:`Dictionary<class_Dictionary>` and :ref:`JSON<class_JSON>` with other functions.
|
||||
|
||||
.. rst-class:: classref-reftable-group
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_notification<class_JSONRPC_method_make_notification>` **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_request<class_JSONRPC_method_make_request>` **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params, :ref:`Variant<class_Variant>` id **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_response<class_JSONRPC_method_make_response>` **(** :ref:`Variant<class_Variant>` result, :ref:`Variant<class_Variant>` id **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_response_error<class_JSONRPC_method_make_response_error>` **(** :ref:`int<class_int>` code, :ref:`String<class_String>` message, :ref:`Variant<class_Variant>` id=null **)** |const| |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`process_action<class_JSONRPC_method_process_action>` **(** :ref:`Variant<class_Variant>` action, :ref:`bool<class_bool>` recurse=false **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`String<class_String>` | :ref:`process_string<class_JSONRPC_method_process_string>` **(** :ref:`String<class_String>` action **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`set_scope<class_JSONRPC_method_set_scope>` **(** :ref:`String<class_String>` scope, :ref:`Object<class_Object>` target **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
.. table::
|
||||
:widths: auto
|
||||
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_notification<class_JSONRPC_method_make_notification>` **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_request<class_JSONRPC_method_make_request>` **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params, :ref:`Variant<class_Variant>` id **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_response<class_JSONRPC_method_make_response>` **(** :ref:`Variant<class_Variant>` result, :ref:`Variant<class_Variant>` id **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_response_error<class_JSONRPC_method_make_response_error>` **(** :ref:`int<class_int>` code, :ref:`String<class_String>` message, :ref:`Variant<class_Variant>` id=null **)** |const| |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`process_action<class_JSONRPC_method_process_action>` **(** :ref:`Variant<class_Variant>` action, :ref:`bool<class_bool>` recurse=false **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`String<class_String>` | :ref:`process_string<class_JSONRPC_method_process_string>` **(** :ref:`String<class_String>` action **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`set_scope<class_JSONRPC_method_set_scope>` **(** :ref:`String<class_String>` scope, :ref:`Object<class_Object>` target **)** |
|
||||
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Enumerations
|
||||
------------
|
||||
|
||||
.. _enum_JSONRPC_ErrorCode:
|
||||
|
||||
.. _class_JSONRPC_constant_PARSE_ERROR:
|
||||
|
||||
.. _class_JSONRPC_constant_INVALID_REQUEST:
|
||||
|
||||
.. _class_JSONRPC_constant_METHOD_NOT_FOUND:
|
||||
|
||||
.. _class_JSONRPC_constant_INVALID_PARAMS:
|
||||
|
||||
.. _class_JSONRPC_constant_INTERNAL_ERROR:
|
||||
.. rst-class:: classref-enumeration
|
||||
|
||||
enum **ErrorCode**:
|
||||
|
||||
- **PARSE_ERROR** = **-32700**
|
||||
.. _class_JSONRPC_constant_PARSE_ERROR:
|
||||
|
||||
- **INVALID_REQUEST** = **-32600**
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
- **METHOD_NOT_FOUND** = **-32601** --- A method call was requested but no function of that name existed in the JSONRPC subclass.
|
||||
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **PARSE_ERROR** = ``-32700``
|
||||
|
||||
- **INVALID_PARAMS** = **-32602**
|
||||
|
||||
- **INTERNAL_ERROR** = **-32603**
|
||||
|
||||
.. _class_JSONRPC_constant_INVALID_REQUEST:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INVALID_REQUEST** = ``-32600``
|
||||
|
||||
|
||||
|
||||
.. _class_JSONRPC_constant_METHOD_NOT_FOUND:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **METHOD_NOT_FOUND** = ``-32601``
|
||||
|
||||
A method call was requested but no function of that name existed in the JSONRPC subclass.
|
||||
|
||||
.. _class_JSONRPC_constant_INVALID_PARAMS:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INVALID_PARAMS** = ``-32602``
|
||||
|
||||
|
||||
|
||||
.. _class_JSONRPC_constant_INTERNAL_ERROR:
|
||||
|
||||
.. rst-class:: classref-enumeration-constant
|
||||
|
||||
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INTERNAL_ERROR** = ``-32603``
|
||||
|
||||
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Method Descriptions
|
||||
-------------------
|
||||
|
||||
.. _class_JSONRPC_method_make_notification:
|
||||
|
||||
- :ref:`Dictionary<class_Dictionary>` **make_notification** **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Dictionary<class_Dictionary>` **make_notification** **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params **)**
|
||||
|
||||
Returns a dictionary in the form of a JSON-RPC notification. Notifications are one-shot messages which do not expect a response.
|
||||
|
||||
@@ -78,11 +121,15 @@ Returns a dictionary in the form of a JSON-RPC notification. Notifications are o
|
||||
|
||||
- ``params``: An array or dictionary of parameters being passed to the method.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JSONRPC_method_make_request:
|
||||
|
||||
- :ref:`Dictionary<class_Dictionary>` **make_request** **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params, :ref:`Variant<class_Variant>` id **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Dictionary<class_Dictionary>` **make_request** **(** :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` params, :ref:`Variant<class_Variant>` id **)**
|
||||
|
||||
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.
|
||||
|
||||
@@ -92,11 +139,15 @@ Returns a dictionary in the form of a JSON-RPC request. Requests are sent to a s
|
||||
|
||||
- ``id``: Uniquely identifies this request. The server is expected to send a response with the same ID.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JSONRPC_method_make_response:
|
||||
|
||||
- :ref:`Dictionary<class_Dictionary>` **make_response** **(** :ref:`Variant<class_Variant>` result, :ref:`Variant<class_Variant>` id **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Dictionary<class_Dictionary>` **make_response** **(** :ref:`Variant<class_Variant>` result, :ref:`Variant<class_Variant>` id **)**
|
||||
|
||||
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.
|
||||
|
||||
@@ -104,11 +155,15 @@ When a server has received and processed a request, it is expected to send a res
|
||||
|
||||
- ``id``: The ID of the request this response is targeted to.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JSONRPC_method_make_response_error:
|
||||
|
||||
- :ref:`Dictionary<class_Dictionary>` **make_response_error** **(** :ref:`int<class_int>` code, :ref:`String<class_String>` message, :ref:`Variant<class_Variant>` id=null **)** |const|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Dictionary<class_Dictionary>` **make_response_error** **(** :ref:`int<class_int>` code, :ref:`String<class_String>` message, :ref:`Variant<class_Variant>` id=null **)** |const|
|
||||
|
||||
Creates a response which indicates a previous reply has failed in some way.
|
||||
|
||||
@@ -118,11 +173,15 @@ Creates a response which indicates a previous reply has failed in some way.
|
||||
|
||||
- ``id``: The request this error is a response to.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JSONRPC_method_process_action:
|
||||
|
||||
- :ref:`Variant<class_Variant>` **process_action** **(** :ref:`Variant<class_Variant>` action, :ref:`bool<class_bool>` recurse=false **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Variant<class_Variant>` **process_action** **(** :ref:`Variant<class_Variant>` action, :ref:`bool<class_bool>` recurse=false **)**
|
||||
|
||||
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.
|
||||
|
||||
@@ -130,21 +189,29 @@ To add new supported methods extend the JSONRPC class and call :ref:`process_act
|
||||
|
||||
\ ``action``: The action to be run, as a Dictionary in the form of a JSON-RPC request or notification.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JSONRPC_method_process_string:
|
||||
|
||||
- :ref:`String<class_String>` **process_string** **(** :ref:`String<class_String>` action **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`String<class_String>` **process_string** **(** :ref:`String<class_String>` action **)**
|
||||
|
||||
.. container:: contribute
|
||||
|
||||
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JSONRPC_method_set_scope:
|
||||
|
||||
- void **set_scope** **(** :ref:`String<class_String>` scope, :ref:`Object<class_Object>` target **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
void **set_scope** **(** :ref:`String<class_String>` scope, :ref:`Object<class_Object>` target **)**
|
||||
|
||||
.. container:: contribute
|
||||
|
||||
|
||||
Reference in New Issue
Block a user