Files
godot-docs-l10n/classes/es/class_jsonrpc.rst
Rémi Verschelde c3f2364c10 Sync classref with 4.6 branch
Lots of translations invalidated (fuzzied) as we just synced Weblate.
2025-12-19 16:39:51 +01:00

226 lines
12 KiB
ReStructuredText

:github_url: hide
.. _class_JSONRPC:
JSONRPC
=======
**Hereda:** :ref:`Object<class_Object>`
Un asistente para manejar diccionarios que parecen documentos JSONRPC.
.. rst-class:: classref-introduction-group
Descripción
----------------------
`JSON-RPC <https://www.jsonrpc.org/>`__ es un estándar que envuelve una llamada a un método en un objeto :ref:`JSON<class_JSON>`. El objeto tiene una estructura particular e identifica qué método se llama, los parámetros de esa función, y lleva un ID para realizar un seguimiento de las respuestas. Esta clase implementa ese estándar sobre :ref:`Dictionary<class_Dictionary>`; tendrás que convertir entre un :ref:`Dictionary<class_Dictionary>` y :ref:`JSON<class_JSON>` con otras funciones.
.. rst-class:: classref-reftable-group
Métodos
--------------
.. table::
:widths: auto
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_notification<class_JSONRPC_method_make_notification>`\ (\ method\: :ref:`String<class_String>`, params\: :ref:`Variant<class_Variant>`\ ) |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_request<class_JSONRPC_method_make_request>`\ (\ method\: :ref:`String<class_String>`, params\: :ref:`Variant<class_Variant>`, id\: :ref:`Variant<class_Variant>`\ ) |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_response<class_JSONRPC_method_make_response>`\ (\ result\: :ref:`Variant<class_Variant>`, id\: :ref:`Variant<class_Variant>`\ ) |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Dictionary<class_Dictionary>` | :ref:`make_response_error<class_JSONRPC_method_make_response_error>`\ (\ code\: :ref:`int<class_int>`, message\: :ref:`String<class_String>`, id\: :ref:`Variant<class_Variant>` = null\ ) |const| |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`process_action<class_JSONRPC_method_process_action>`\ (\ action\: :ref:`Variant<class_Variant>`, recurse\: :ref:`bool<class_bool>` = false\ ) |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`process_string<class_JSONRPC_method_process_string>`\ (\ action\: :ref:`String<class_String>`\ ) |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_method<class_JSONRPC_method_set_method>`\ (\ name\: :ref:`String<class_String>`, callback\: :ref:`Callable<class_Callable>`\ ) |
+-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumeraciones
--------------------------
.. _enum_JSONRPC_ErrorCode:
.. rst-class:: classref-enumeration
enum **ErrorCode**: :ref:`🔗<enum_JSONRPC_ErrorCode>`
.. _class_JSONRPC_constant_PARSE_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **PARSE_ERROR** = ``-32700``
La solicitud no pudo ser analizada ya que no era válida según el estándar JSON (falló :ref:`JSON.parse()<class_JSON_method_parse>`).
.. _class_JSONRPC_constant_INVALID_REQUEST:
.. rst-class:: classref-enumeration-constant
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INVALID_REQUEST** = ``-32600``
Se solicitó una llamada a un método, pero el formato de la solicitud no es válido.
.. _class_JSONRPC_constant_METHOD_NOT_FOUND:
.. rst-class:: classref-enumeration-constant
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **METHOD_NOT_FOUND** = ``-32601``
Se solicitó una llamada a un método, pero no existía ninguna función con ese nombre en la subclase JSONRPC.
.. _class_JSONRPC_constant_INVALID_PARAMS:
.. rst-class:: classref-enumeration-constant
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INVALID_PARAMS** = ``-32602``
Se solicitó una llamada a un método, pero los parámetros del método dado no son válidos. No utilizado por el JSONRPC incorporado.
.. _class_JSONRPC_constant_INTERNAL_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INTERNAL_ERROR** = ``-32603``
Ocurrió un error interno al procesar la solicitud. No utilizado por el JSONRPC incorporado.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Descripciones de Métodos
------------------------------------------------
.. _class_JSONRPC_method_make_notification:
.. rst-class:: classref-method
:ref:`Dictionary<class_Dictionary>` **make_notification**\ (\ method\: :ref:`String<class_String>`, params\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_JSONRPC_method_make_notification>`
Devuelve un diccionario en forma de notificación JSON-RPC. Las notificaciones son mensajes de una sola vez que no esperan una respuesta.
- ``method``: Nombre del método que se está llamando.
- ``params``: Un array o diccionario de parámetros que se pasan al método.
.. rst-class:: classref-item-separator
----
.. _class_JSONRPC_method_make_request:
.. rst-class:: classref-method
:ref:`Dictionary<class_Dictionary>` **make_request**\ (\ method\: :ref:`String<class_String>`, params\: :ref:`Variant<class_Variant>`, id\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_JSONRPC_method_make_request>`
Devuelve un diccionario en forma de solicitud JSON-RPC. Las solicitudes se envían a un servidor con la expectativa de una respuesta. El campo ID se utiliza para que el servidor especifique a qué solicitud exacta está respondiendo.
- ``method``: Nombre del método que se está llamando.
- ``params``: Un array o diccionario de parámetros que se pasan al método.
- ``id``: Identifica de forma única esta solicitud. Se espera que el servidor envíe una respuesta con el mismo ID.
.. rst-class:: classref-item-separator
----
.. _class_JSONRPC_method_make_response:
.. rst-class:: classref-method
:ref:`Dictionary<class_Dictionary>` **make_response**\ (\ result\: :ref:`Variant<class_Variant>`, id\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_JSONRPC_method_make_response>`
Cuando un servidor ha recibido y procesado una solicitud, se espera que envíe una respuesta. Si no querías una respuesta, entonces necesitas haber enviado una Notificación en su lugar.
- ``result``: El valor de retorno de la función que fue llamada.
- ``id``: El ID de la solicitud a la que se dirige esta respuesta.
.. rst-class:: classref-item-separator
----
.. _class_JSONRPC_method_make_response_error:
.. rst-class:: classref-method
:ref:`Dictionary<class_Dictionary>` **make_response_error**\ (\ code\: :ref:`int<class_int>`, message\: :ref:`String<class_String>`, id\: :ref:`Variant<class_Variant>` = null\ ) |const| :ref:`🔗<class_JSONRPC_method_make_response_error>`
Creates a response which indicates a previous reply has failed in some way.
- ``code``: The error code corresponding to what kind of error this is. See the :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` constants.
- ``message``: A custom message about this error.
- ``id``: The request this error is a response to.
.. rst-class:: classref-item-separator
----
.. _class_JSONRPC_method_process_action:
.. rst-class:: classref-method
:ref:`Variant<class_Variant>` **process_action**\ (\ action\: :ref:`Variant<class_Variant>`, recurse\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_JSONRPC_method_process_action>`
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 :ref:`process_action()<class_JSONRPC_method_process_action>` on your subclass.
\ ``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:
.. rst-class:: classref-method
:ref:`String<class_String>` **process_string**\ (\ action\: :ref:`String<class_String>`\ ) :ref:`🔗<class_JSONRPC_method_process_string>`
.. container:: contribute
There is currently no description for this method. Please help us by `contributing one <https://contributing.godotengine.org/en/latest/documentation/class_reference.html>`__!
.. rst-class:: classref-item-separator
----
.. _class_JSONRPC_method_set_method:
.. rst-class:: classref-method
|void| **set_method**\ (\ name\: :ref:`String<class_String>`, callback\: :ref:`Callable<class_Callable>`\ ) :ref:`🔗<class_JSONRPC_method_set_method>`
Registers a callback for the given method name.
- ``name``: The name that clients can use to access the callback.
- ``callback``: The callback which will handle the specified method.
.. |virtual| replace:: :abbr:`virtual (Normalmente, este método debería ser sobreescrito por el usuario para que tenga algún efecto.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (Este método no tiene efectos secundarios. No modifica ninguna de las variables miembro de la instancia.)`
.. |vararg| replace:: :abbr:`vararg (Este método permite agregar cualquier número de argumentos después de los descritos aquí.)`
.. |constructor| replace:: :abbr:`constructor (Este método se utiliza para construir un tipo.)`
.. |static| replace:: :abbr:`static (Este método no necesita una instancia para ser llamado, por lo que puede llamarse directamente utilizando el nombre de la clase.)`
.. |operator| replace:: :abbr:`operator (Este método describe un operador válido para usar con este tipo como operando izquierdo.)`
.. |bitfield| replace:: :abbr:`BitField (Este valor es un entero compuesto como una máscara de bits de las siguientes banderas.)`
.. |void| replace:: :abbr:`void (Sin valor de retorno.)`