Ejemplo n.º 1
0
    @Override
    public PduResponse firePduRequestReceived(PduRequest pduRequest) {
      SmppSession session = sessionRef.get();

      // mimic how long processing could take on a slower smsc
      // processing received SMPP message from Restcomm
      String decodedPduMessage = null;
      String destSmppAddress = null;
      String sourceSmppAddress = null;

      if (pduRequest.toString().toLowerCase().contains("enquire_link")) {
        // logger.info("This is a response to the enquire_link, therefore, do NOTHING ");
      } else {

        // smppOutBoundMessageReceivedByServer = true;
        logger.info("********Restcomm Message Received By SMPP Server*******");

        try {
          SubmitSm deliverSm = (SubmitSm) pduRequest;
          decodedPduMessage = CharsetUtil.CHARSET_MODIFIED_UTF8.decode(deliverSm.getShortMessage());
          destSmppAddress = deliverSm.getDestAddress().getAddress();
          sourceSmppAddress = deliverSm.getSourceAddress().getAddress();
          logger.info("getDataCoding: " + deliverSm.getDataCoding());
          // send received SMPP PDU message to restcomm
        } catch (Exception e) {
          logger.info("********DeliverSm Exception******* " + e);
        }

        smppInboundMessageEntity =
            new SmppInboundMessageEntity(
                destSmppAddress, sourceSmppAddress, decodedPduMessage, CharsetUtil.CHARSET_GSM);
        messageReceived = true;
      }
      return pduRequest.createResponse();
    }
    @Override
    public PduResponse firePduRequestReceived(PduRequest pduRequest) {
      SmppSession session = sessionRef.get();

      SubmitSm req = (SubmitSm) pduRequest;

      String str = CharsetUtil.decode(req.getShortMessage(), CharsetUtil.CHARSET_MODIFIED_UTF8);

      // SmsDTO smsDTO = new SmsDTO();
      smsDTO.setBody(str);
      smsDTO.setSender(req.getSourceAddress().getAddress());
      smsDTO.setDeliveryDate(new Date());
      smsDTO.setSendDate(new Date());

      // SmsDAOImpl smsDAO = new SmsDAOImpl();
      smsDAO.save(smsDTO);

      return pduRequest.createResponse();
    }