Add isMethodSupported handler
Summary: Allows plugin to check if something is supported by that app, for example an extension command or a new feature, before trying to use it. Reviewed By: passy Differential Revision: D14225957 fbshipit-source-id: 3c5a29a06b56fe5f1da772824232547447872344
This commit is contained in:
committed by
Facebook Github Bot
parent
dbb4fa1191
commit
40ada838d7
@@ -231,6 +231,22 @@ void FlipperClient::onMessageReceived(
|
||||
return;
|
||||
}
|
||||
|
||||
if (method == "isMethodSupported") {
|
||||
const auto identifier = params["api"].getString();
|
||||
if (connections_.find(identifier) == connections_.end()) {
|
||||
std::string errorMessage = "Connection " + identifier +
|
||||
" not found for method " + method.getString();
|
||||
log(errorMessage);
|
||||
responder->error(folly::dynamic::object("message", errorMessage)(
|
||||
"name", "ConnectionNotFound"));
|
||||
return;
|
||||
}
|
||||
const auto& conn = connections_.at(params["api"].getString());
|
||||
bool isSupported = conn->hasReceiver(params["method"].getString());
|
||||
responder->success(dynamic::object("isSupported", isSupported));
|
||||
return;
|
||||
}
|
||||
|
||||
dynamic response =
|
||||
dynamic::object("message", "Received unknown method: " + method);
|
||||
responder->error(response);
|
||||
|
||||
Reference in New Issue
Block a user