class_jsonrpc.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/JSONRPC.xml.
  6. .. _class_JSONRPC:
  7. JSONRPC
  8. =======
  9. **Inherits:** :ref:`Object<class_Object>`
  10. A helper to handle dictionaries which look like JSONRPC documents.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. `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.
  15. .. rst-class:: classref-reftable-group
  16. Methods
  17. -------
  18. .. table::
  19. :widths: auto
  20. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Dictionary<class_Dictionary>` | :ref:`make_notification<class_JSONRPC_method_make_notification>`\ (\ method\: :ref:`String<class_String>`, params\: :ref:`Variant<class_Variant>`\ ) |
  22. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :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>`\ ) |
  24. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Dictionary<class_Dictionary>` | :ref:`make_response<class_JSONRPC_method_make_response>`\ (\ result\: :ref:`Variant<class_Variant>`, id\: :ref:`Variant<class_Variant>`\ ) |
  26. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :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| |
  28. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Variant<class_Variant>` | :ref:`process_action<class_JSONRPC_method_process_action>`\ (\ action\: :ref:`Variant<class_Variant>`, recurse\: :ref:`bool<class_bool>` = false\ ) |
  30. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_String>` | :ref:`process_string<class_JSONRPC_method_process_string>`\ (\ action\: :ref:`String<class_String>`\ ) |
  32. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | |void| | :ref:`set_scope<class_JSONRPC_method_set_scope>`\ (\ scope\: :ref:`String<class_String>`, target\: :ref:`Object<class_Object>`\ ) |
  34. +-------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. .. rst-class:: classref-section-separator
  36. ----
  37. .. rst-class:: classref-descriptions-group
  38. Enumerations
  39. ------------
  40. .. _enum_JSONRPC_ErrorCode:
  41. .. rst-class:: classref-enumeration
  42. enum **ErrorCode**: :ref:`🔗<enum_JSONRPC_ErrorCode>`
  43. .. _class_JSONRPC_constant_PARSE_ERROR:
  44. .. rst-class:: classref-enumeration-constant
  45. :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **PARSE_ERROR** = ``-32700``
  46. The request could not be parsed as it was not valid by JSON standard (:ref:`JSON.parse<class_JSON_method_parse>` failed).
  47. .. _class_JSONRPC_constant_INVALID_REQUEST:
  48. .. rst-class:: classref-enumeration-constant
  49. :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INVALID_REQUEST** = ``-32600``
  50. A method call was requested but the request's format is not valid.
  51. .. _class_JSONRPC_constant_METHOD_NOT_FOUND:
  52. .. rst-class:: classref-enumeration-constant
  53. :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **METHOD_NOT_FOUND** = ``-32601``
  54. A method call was requested but no function of that name existed in the JSONRPC subclass.
  55. .. _class_JSONRPC_constant_INVALID_PARAMS:
  56. .. rst-class:: classref-enumeration-constant
  57. :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INVALID_PARAMS** = ``-32602``
  58. A method call was requested but the given method parameters are not valid. Not used by the built-in JSONRPC.
  59. .. _class_JSONRPC_constant_INTERNAL_ERROR:
  60. .. rst-class:: classref-enumeration-constant
  61. :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` **INTERNAL_ERROR** = ``-32603``
  62. An internal error occurred while processing the request. Not used by the built-in JSONRPC.
  63. .. rst-class:: classref-section-separator
  64. ----
  65. .. rst-class:: classref-descriptions-group
  66. Method Descriptions
  67. -------------------
  68. .. _class_JSONRPC_method_make_notification:
  69. .. rst-class:: classref-method
  70. :ref:`Dictionary<class_Dictionary>` **make_notification**\ (\ method\: :ref:`String<class_String>`, params\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_JSONRPC_method_make_notification>`
  71. Returns a dictionary in the form of a JSON-RPC notification. Notifications are one-shot messages which do not expect a response.
  72. - ``method``: Name of the method being called.
  73. - ``params``: An array or dictionary of parameters being passed to the method.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _class_JSONRPC_method_make_request:
  77. .. rst-class:: classref-method
  78. :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>`
  79. 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.
  80. - ``method``: Name of the method being called.
  81. - ``params``: An array or dictionary of parameters being passed to the method.
  82. - ``id``: Uniquely identifies this request. The server is expected to send a response with the same ID.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_JSONRPC_method_make_response:
  86. .. rst-class:: classref-method
  87. :ref:`Dictionary<class_Dictionary>` **make_response**\ (\ result\: :ref:`Variant<class_Variant>`, id\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_JSONRPC_method_make_response>`
  88. 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.
  89. - ``result``: The return value of the function which was called.
  90. - ``id``: The ID of the request this response is targeted to.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_JSONRPC_method_make_response_error:
  94. .. rst-class:: classref-method
  95. :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>`
  96. Creates a response which indicates a previous reply has failed in some way.
  97. - ``code``: The error code corresponding to what kind of error this is. See the :ref:`ErrorCode<enum_JSONRPC_ErrorCode>` constants.
  98. - ``message``: A custom message about this error.
  99. - ``id``: The request this error is a response to.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_JSONRPC_method_process_action:
  103. .. rst-class:: classref-method
  104. :ref:`Variant<class_Variant>` **process_action**\ (\ action\: :ref:`Variant<class_Variant>`, recurse\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_JSONRPC_method_process_action>`
  105. 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.
  106. To add new supported methods extend the JSONRPC class and call :ref:`process_action<class_JSONRPC_method_process_action>` on your subclass.
  107. \ ``action``: The action to be run, as a Dictionary in the form of a JSON-RPC request or notification.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_JSONRPC_method_process_string:
  111. .. rst-class:: classref-method
  112. :ref:`String<class_String>` **process_string**\ (\ action\: :ref:`String<class_String>`\ ) :ref:`🔗<class_JSONRPC_method_process_string>`
  113. .. container:: contribute
  114. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_JSONRPC_method_set_scope:
  118. .. rst-class:: classref-method
  119. |void| **set_scope**\ (\ scope\: :ref:`String<class_String>`, target\: :ref:`Object<class_Object>`\ ) :ref:`🔗<class_JSONRPC_method_set_scope>`
  120. .. container:: contribute
  121. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  122. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  123. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  124. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  125. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  126. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  127. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  128. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  129. .. |void| replace:: :abbr:`void (No return value.)`