Debian Codegraph @

modules/jsonrpc/jsonrpc.h

raw symbols SCIP
1 /**************************************************************************/
2 /* jsonrpc.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/object/class_db.h"
34 #include "core/variant/variant.h"
35
36 class JSONRPC : public Object {
37 GDCLASS(JSONRPC, Object)
38
39 HashMap<String, Callable> methods;
40
41 protected:
42 static void _bind_methods();
43
44 #ifndef DISABLE_DEPRECATED
45 void _set_scope_bind_compat_104890(const String &p_scope, Object *p_obj);
46 static void _bind_compatibility_methods();
47 #endif
48
49 public:
50 JSONRPC();
51 ~JSONRPC();
52
53 enum ErrorCode {
54 PARSE_ERROR = -32700,
55 INVALID_REQUEST = -32600,
56 METHOD_NOT_FOUND = -32601,
57 INVALID_PARAMS = -32602,
58 INTERNAL_ERROR = -32603,
59 };
60
61 Dictionary make_response_error(int p_code, const String &p_message, const Variant &p_id = Variant()) const;
62 Dictionary make_response(const Variant &p_value, const Variant &p_id);
63 Dictionary make_notification(const String &p_method, const Variant &p_params);
64 Dictionary make_request(const String &p_method, const Variant &p_params, const Variant &p_id);
65
66 Variant process_action(const Variant &p_action, bool p_process_arr_elements = false);
67 String process_string(const String &p_input);
68
69 void set_method(const String &p_name, const Callable &p_callback);
70 };
71
72 VARIANT_ENUM_CAST(JSONRPC::ErrorCode);