use of org.apache.axis2.transport.sms.SMSMessage in project wso2-axis2-transports by wso2.
the class GSMImplManager method sendSMS.
public void sendSMS(SMSMessage sm) throws AxisFault {
if (service == null && !serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) {
// Operating in the Out Only mode
service = new Service();
gateway = new SerialModemGateway(gsmTransportOutDetails.getGatewayId(), gsmTransportOutDetails.getComPort(), gsmTransportOutDetails.getBaudRate(), gsmTransportOutDetails.getManufacturer(), gsmTransportOutDetails.getModel());
// Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
gateway.setProtocol(AGateway.Protocols.PDU);
// Do we want the Gateway to be used for Outbound messages?
gateway.setOutbound(true);
// Let SMSLib know which is the SIM PIN.
gateway.setSimPin("0000");
try {
// Add the Gateway to the Service object.
this.service.addGateway(gateway);
// Similarly, you may define as many Gateway objects, representing
// various GSM modems, add them in the Service object and control all of them.
// Start! (i.e. connect to all defined Gateways)
this.service.startService();
} catch (Exception e) {
throw new AxisFault(e.getMessage(), e);
}
} else if (serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) {
service = serviceRepo.getService(gsmTransportOutDetails.getGatewayId());
}
OutboundMessage msg = new OutboundMessage(sm.getReceiver(), sm.getContent());
try {
// a blocking call.This will be blocked untill the message is sent.
// normal rate is about 6msgs per minute
service.sendMessage(msg);
} catch (Exception e) {
throw new AxisFault(e.getMessage(), e);
}
}
use of org.apache.axis2.transport.sms.SMSMessage in project wso2-axis2-transports by wso2.
the class SMPPDispatcher method dispatch.
void dispatch(String source, String receiver, String message, Map<String, Object> properties) throws AxisFault {
synchronized (this) {
smsMessage = new SMSMessage(source, receiver, message, SMSMessage.IN_MESSAGE);
smsMessage.getProperties().putAll(properties);
}
manager.dispatchToAxis2(smsMessage);
}
Aggregations