| 170 | } |
| 171 | |
| 172 | String JSONRPC::process_string(const String &p_input) { |
| 173 | if (p_input.is_empty()) { |
| 174 | return String(); |
| 175 | } |
| 176 | |
| 177 | Variant ret; |
| 178 | JSON json; |
| 179 | if (json.parse(p_input) == OK) { |
| 180 | ret = process_action(json.get_data(), true); |
| 181 | } else { |
| 182 | ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error"); |
| 183 | } |
| 184 | |
| 185 | if (ret.get_type() == Variant::NIL) { |
| 186 | return ""; |
| 187 | } |
| 188 | return ret.to_json_string(); |
| 189 | } |
| 190 | |
| 191 | void JSONRPC::set_method(const String &p_name, const Callable &p_callback) { |
| 192 | methods[p_name] = p_callback; |