ClientCommandSender sender = agent.getClientCommandSender();
if (sender != null) {
if (numberOfTimes == 1) {
// if executing it just one time, then do so synchronously
Ping ping = sender.getClientRemotePojoFactory().getRemotePojo(Ping.class);
agent.getOut().println(MSG.getMsg(AgentI18NResourceKeys.PING_PINGING));
String ping_results = ping.ping("PING", "Ack: ");
agent.getOut().println(MSG.getMsg(AgentI18NResourceKeys.PING_PING_RESULTS, ping_results));
} else {
ClientRemotePojoFactory factory = sender.getClientRemotePojoFactory();
factory.setDeliveryGuaranteed(guaranteed);
factory.setAsynch(true, new Callback(agent));
Ping ping = factory.getRemotePojo(Ping.class);
for (int i = 0; i < numberOfTimes; i++) {
agent.getOut().println(MSG.getMsg(AgentI18NResourceKeys.PING_ASYNC_PING, i, guaranteed));
ping.ping("PING", "Ack #"
+ i
+ ((ClientRemotePojoFactory.GuaranteedDelivery.YES == guaranteed) ? (" ("
+ MSG.getMsg(AgentI18NResourceKeys.PING_GUARANTEED) + ")") : "") + ": ");
}
}