link.thingscloud.freeswitch.esl.transport.CommandResponse Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package link.thingscloud.freeswitch.esl.transport;
import link.thingscloud.freeswitch.esl.transport.message.EslHeaders;
import link.thingscloud.freeswitch.esl.transport.message.EslMessage;
/**
* CommandResponse class.
*
* @author : zhouhailin
* @version 1.0.0
*/
public class CommandResponse {
private final String command;
private final String replyText;
private final EslMessage response;
private final boolean success;
/**
* Constructor for CommandResponse.
*
* @param command a {@link java.lang.String} object.
* @param response a {@link link.thingscloud.freeswitch.esl.transport.message.EslMessage} object.
*/
public CommandResponse(String command, EslMessage response) {
this.command = command;
this.response = response;
this.replyText = response == null ? "" : response.getHeaderValue(EslHeaders.Name.REPLY_TEXT);
this.success = replyText.startsWith("+OK");
}
/**
* Getter for the field command
.
*
* @return the original command sent to the server
*/
public String getCommand() {
return command;
}
/**
* isOk.
*
* @return true if and only if the response Reply-Text line starts with "+OK"
*/
public boolean isOk() {
return success;
}
/**
* Getter for the field replyText
.
*
* @return the full response Reply-Text line.
*/
public String getReplyText() {
return replyText;
}
/**
* Getter for the field response
.
*
* @return {@link link.thingscloud.freeswitch.esl.transport.message.EslMessage} the full response from the server
*/
public EslMessage getResponse() {
return response;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy