use of com.cloudhopper.smpp.SmppSession in project smscgateway by RestComm.
the class SendAction method execute.
@Override
public void execute(ScenarioState s, ScenarioState s1, ScenarioEvent e, ScenarioContext ctx, ScenarioFSM t) {
try {
SmppSession session = (SmppSession) ctx.data.get("SmppSession");
ScenarioStep step = ctx.globalContext.scenarioXml.getSteps().get(ctx.currentStep);
Class pduClass = this.getClass().getClassLoader().loadClass(step.getCmdArguments().get(0));
PduRequest pdu = (PduRequest) pduClass.newInstance();
for (int i = 0; i < step.getCmdArguments().size() - 1; i++) {
String cmdArg = step.getCmdArguments().get(i + 1);
String[] split = cmdArg.split("=");
if (split.length >= 2) {
BeanUtils.setProperty(pdu, split[0], split[1]);
} else {
throw new RuntimeException("Unknown send argument syntax");
}
}
// this allows to receive response in proper fsm
pdu.setReferenceObject(ctx);
session.sendRequestPdu(pdu, step.getTimeout(), false);
ctx.fsm.fire(ScenarioEvent.MSG_SENT, ctx);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of com.cloudhopper.smpp.SmppSession in project smscgateway by RestComm.
the class SMPPInitializer method init.
@Override
public void init(GlobalContext ctx) throws Exception {
DefaultSmppClient clientBootstrap = new DefaultSmppClient(Executors.newCachedThreadPool(), ctx.getIntegerProp("smppp.smppStack.sessionCount"), ctx.executor);
// same configuration for each client runner
SmppSessionConfiguration config = new SmppSessionConfiguration();
config.setWindowSize(ctx.getIntegerProp("smppp.smppStack.windowSize"));
config.setName(ctx.getProperty("smppp.smppStack.name"));
config.setType(SmppBindType.valueOf(ctx.getProperty("smppp.smppStack.type")));
config.setHost(ctx.getProperty("smppp.smppStack.host"));
config.setPort(ctx.getIntegerProp("smppp.smppStack.port"));
config.setConnectTimeout(ctx.getIntegerProp("smppp.smppStack.connectTimeout"));
config.setSystemId(ctx.getProperty("smppp.smppStack.systemId"));
config.setPassword(ctx.getProperty("smppp.smppStack.password"));
config.getLoggingOptions().setLogBytes(Boolean.valueOf(ctx.getProperty("smppp.smppStack.logBytes")));
// to enable monitoring (request expiration)
config.setRequestExpiryTimeout(ctx.getIntegerProp("smppp.smppStack.requestExpiryTimeout"));
config.setWindowMonitorInterval(ctx.getIntegerProp("smppp.smppStack.windowMonitorInterval"));
config.setCountersEnabled(Boolean.valueOf(ctx.getProperty("smppp.smppStack.countersEnabled")));
DefaultSmppSessionHandler sessionHandler = (DefaultSmppSessionHandler) ctx.scenario;
List<SmppSession> sessionList = new ArrayList(ctx.getIntegerProp("smppp.smppStack.sessionCount"));
for (int i = 0; i < ctx.getIntegerProp("smppp.smppStack.sessionCount"); i++) {
sessionList.add(clientBootstrap.bind(config, sessionHandler));
}
ctx.data.put("SMPPSessionList", sessionList);
CyclicCounter sessionCounter = new CyclicCounter(ctx.getIntegerProp("smppp.smppStack.sessionCount"));
ctx.data.put("sessionCounter", sessionCounter);
ctx.fsm.fire(GlobalEvent.ASSOCIATION_UP, ctx);
}
Aggregations