use of org.freeswitch.esl.client.transport.message.EslMessage in project openhab1-addons by openhab.
the class FreeswitchBinding method executeApiCommand.
/**
* Execute a api command and return the body as a
* single comma delimited String
*
* @param command
* @return Each line of the response will be appended to the string,
* delimited by a comma
*/
public String executeApiCommand(String command) {
logger.debug("Trying to execute API command {}", command);
if (!clientValid() && StringUtils.isBlank(command)) {
logger.error("Bad command {}", command);
return null;
}
String[] args = command.split(" ", 1);
/*
* if we do not have 2 args then this is not valid
*/
if (args.length == 0) {
logger.error("Command did not contain a valid command string {}");
return null;
}
EslMessage msg = inboudClient.sendSyncApiCommand(args[0], args.length > 1 ? args[1] : "");
List<String> bodyLines = msg.getBodyLines();
StringBuilder builder = new StringBuilder();
for (String line : bodyLines) {
if (builder.length() > 0) {
builder.append(",");
}
builder.append(line);
}
return builder.toString();
}
Aggregations