use of org.smpp.pdu.DeliverSM in project opensmpp by OpenSmpp.
the class DeliveryInfoSender method deliver.
private void deliver(DeliveryInfoEntry entry) {
debug.enter(this, "deliver");
SubmitSM submit = entry.submit;
DeliverSM deliver = new DeliverSM();
deliver.setEsmClass((byte) Data.SM_SMSC_DLV_RCPT_TYPE);
deliver.setSourceAddr(submit.getDestAddr());
deliver.setDestAddr(submit.getDestAddr());
// ISO-Latin-1
deliver.setDataCoding((byte) 0x03);
String msg = "";
msg += "id:" + entry.messageId + " ";
msg += "sub:" + entry.sub + " ";
msg += "dlvrd:" + entry.dlvrd + " ";
msg += "submit date:" + formatDate(entry.submitted) + " ";
msg += "done date:" + formatDate(System.currentTimeMillis()) + " ";
msg += "stat:" + states[entry.stat] + " ";
msg += "err:" + entry.err + " ";
String shortMessage = submit.getShortMessage();
int msgLen = shortMessage.length();
msg += "text:" + shortMessage.substring(0, (msgLen > 20 ? 20 : msgLen));
try {
deliver.setShortMessage(msg);
deliver.setServiceType(submit.getServiceType());
} catch (WrongLengthOfStringException e) {
}
try {
entry.processor.serverRequest(deliver);
} catch (Exception e) {
}
debug.exit(this);
}
use of org.smpp.pdu.DeliverSM in project opensmpp by OpenSmpp.
the class Simulator method sendMessage.
/**
* Permits data to be sent to a specific client.
* With the id of the client set by the user, the method <code>sendMessage</code>
* gets back the specific reference to the client's <code>PDUProcessor</code>.
* With this reference you are able to send data to the client.
*/
protected void sendMessage() throws IOException {
if (smscListener != null) {
int procCount = processors.count();
if (procCount > 0) {
String client;
SimulatorPDUProcessor proc;
listClients();
if (procCount > 1) {
System.out.print("Type name of the destination> ");
client = keyboard.readLine();
} else {
proc = (SimulatorPDUProcessor) processors.get(0);
client = proc.getSystemId();
}
for (int i = 0; i < procCount; i++) {
proc = (SimulatorPDUProcessor) processors.get(i);
if (proc.getSystemId().equals(client)) {
if (proc.isActive()) {
System.out.print("Type the message> ");
String message = keyboard.readLine();
DeliverSM request = new DeliverSM();
try {
request.setShortMessage(message);
proc.serverRequest(request);
System.out.println("Message sent.");
} catch (WrongLengthOfStringException e) {
System.out.println("Message sending failed");
event.write(e, "");
} catch (IOException ioe) {
} catch (PDUException pe) {
}
} else {
System.out.println("This session is inactive.");
}
}
}
} else {
System.out.println("No client connected.");
}
} else {
System.out.println("You must start listener first.");
}
}
Aggregations