Using Host Communications to Send Commands
You need a working Red App project with an Activator class.
-
Using Eclipse, add the following required dependencies:
-
com.sabre.edge.cf.core
-
com.sabre.edge.cf.model
-
com.sabre.edge.cf.host
-
-
Add the following Java code to consume a service that is registered with SRWRuntime. Obtain a reference to ISRWCommunication service:
ISRWCommunication com = Activator.getDefault().getServiceReference(ISRWCommunication.class);
-
Create an instance of HostServiceClient class or AggregatedResponseHostServiceClient if returns multiple reponses and call send() method with an instance of HostCommand class.
String command = "1LASLAX";
ClientResponse <HostResponse> rsp =new HostServiceClient(com).send(new HostCommand(command));
or
String command = "CFLAX/15FEB-20FEB/1P-1P/ECAR/ID-ZI1456D,ET564389";
ClientResponse <AggregatedHostResponse> rsp =
new AggregatedResponseHostServiceClient(com).send(new HostCommand(command));
-
Retrieve a response to ClientResponse<HostResponse> reference. This class provides simply methods isSuccess() to check for status, getErrors() retrieving errors (if occurred) and getPayload()to obtain a response.
if (rsp.isSuccess())
{
showMessage(rsp.getPayload().getText());
}
or when using AggregatedResponseHostServiceClient
if (rsp.isSuccess())
{
for(HostResponse response: rsp.getPayload().getResponses()) {
appendMessage(response.getText());
}
}
-
Create your redapp.xml configuration file and add an Authorization entry to the file to use the host communications service. For instance:
<Authorization name="com.sabre.edge.cf.host.AggregatedResponseCommunication" threshold="10" metric="tpm" />
<Authorization name="com.sabre.edge.cf.host.Communication" threshold="10" metric="tpm" />