Search in sources :

Example 1 with DeliverSM

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);
}
Also used : WrongLengthOfStringException(org.smpp.pdu.WrongLengthOfStringException) SubmitSM(org.smpp.pdu.SubmitSM) WrongLengthOfStringException(org.smpp.pdu.WrongLengthOfStringException) DeliverSM(org.smpp.pdu.DeliverSM)

Example 2 with DeliverSM

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.");
    }
}
Also used : SimulatorPDUProcessor(org.smpp.smscsim.SimulatorPDUProcessor) WrongLengthOfStringException(org.smpp.pdu.WrongLengthOfStringException) PDUException(org.smpp.pdu.PDUException) DeliverSM(org.smpp.pdu.DeliverSM)

Aggregations

DeliverSM (org.smpp.pdu.DeliverSM)2 WrongLengthOfStringException (org.smpp.pdu.WrongLengthOfStringException)2 PDUException (org.smpp.pdu.PDUException)1 SubmitSM (org.smpp.pdu.SubmitSM)1 SimulatorPDUProcessor (org.smpp.smscsim.SimulatorPDUProcessor)1