Examples of PDU


Examples of com.cloudhopper.smpp.pdu.Pdu

    }
   
    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
      if (e.getMessage() instanceof Pdu) {
            Pdu pdu = (Pdu)e.getMessage();
            this.listener.firePduReceived(pdu);
      }
    }
View Full Code Here

Examples of com.logica.smpp.pdu.PDU

   * @todo implement functionality to handle Data PDUs.
   */
  @Override
  public boolean receive (SmppResponseInterface response, long timeout)
  {
    PDU pdu = null;
    try {
      myLog.error ("receive - calling getSession ().receive");
      pdu = getSession ().receive (timeout);
    }
    catch (UnknownCommandIdException exc) {
      myLog.error ("receive - unknown command", exc);
      return false;
    }
    catch (TimeoutException exc) {
      myLog.error ("receive - timeout establishing connection", exc);
      return false;
    }
    catch (PDUException exc) {
      myLog.error ("receive - exception in pdu", exc);
      return false;
    }
    catch (NotSynchronousException exc) {
      myLog.error ("receive - non synchronous", exc);
      return false;
    }
    catch (IOException exc) {
      myLog.error ("receive - io exception (socket problem?)", exc);
      return false;
    }

    if (pdu == null) {
      return false;
    }
    else {
      myLog.error ("receive - received pdu: {}", pdu.debugString ());
      response.setCommand (SmppCommandType.decode (pdu.getCommandId ()));
      if (pdu instanceof DeliverSM) {
        DeliverSM deliver = (DeliverSM)pdu;
        updateResponse (response, deliver);

        // send DeliverSMResp
        try {
          getSession ().respond (deliver.getResponse ());
        }
        catch (ValueNotSetException exc) {
          myLog.error ("receive - value not set", exc);
          return false;
        }
        catch (WrongSessionStateException exc) {
          myLog.error ("receive - session state wrong", exc);
          return false;
        }
        catch (IOException exc) {
          myLog.error ("receive - io exception (socket problem?)", exc);
          return false;
        }

        return true;
      }
      else if (pdu instanceof DataSM) {
        DataSM data = (DataSM)pdu;
        myLog.error ("receive - data message not supported: {}", data.debugString ());
        return false;
      }
      else {
        myLog.error ("receive - pdu not recognised {}", pdu.debugString ());
        return false;
      }
    }
  }
View Full Code Here

Examples of com.logica.smpp.pdu.PDU

   * work (i.e. only place objects in the queue) so that PDUs can
   * continue to be received.</p>
   */
  public void handleEvent (ServerPDUEvent event)
  {
    PDU pdu = event.getPDU ();
    if (pdu.isRequest ()) {
      if (pdu instanceof DeliverSM) {
        handleDeliverEvent (event);
      }
      else if (pdu instanceof DataSM) {
        handleDataEvent (event);
      }
      else {
        myLog.warn ("handleEvent -ignored async request: {}", pdu.debugString ());
      }
    }
    else if (pdu.isResponse ()) {
      if (pdu instanceof EnquireLinkResp) {
        if (myQueueEnquireLink) {
          handleEnquireLinkResponseEvent (event);
        }
        else {
          myLog.debug ("handleEvent - async response: {}", pdu.debugString ());
        }
      }
      else if (pdu instanceof SubmitSMResp) {
        handleSubmitResponseEvent (event);
      }
      else if (pdu instanceof QuerySMResp) {
        handleQueryResponseEvent (event);
      }
      else {
        myLog.error ("handleEvent - ignored async response: {}", pdu.debugString ());
      }
    }
    else {
      myLog.error ("handleEvent - unknown class: {}", pdu.debugString ());
    }
  }
View Full Code Here

Examples of com.logica.smpp.pdu.PDU

  @Override
  public boolean receive (SmppResponseInterface response, long timeout)
  {
    ServerPDUEvent server = getEventListener ().getDeliverEvent (timeout);
    if (server != null) {
      PDU pdu = server.getPDU ();
      if (pdu instanceof DeliverSM) {
        return updateResponse (response, (DeliverSM)(pdu));
      }
      else if (pdu instanceof DataSM) {
        myLog.error ("receive - data message not supported: {}", pdu.debugString ());
      }
      else {
        myLog.error ("receive - pdu not recognised {}", pdu.debugString ());
        return false;
      }
    }
    return false;
  }
View Full Code Here

Examples of org.ajwcc.pduUtils.gsm3040.Pdu

  {
    boolean ok = false;
    List<String> pdus = msg.getPdus(getSmscNumber(), this.outMpRefNo);
    for (String pdu : pdus)
    {
      Pdu newPdu = new PduParser().parsePdu(pdu);
      Logger.getInstance().logDebug(newPdu.toString(), null, getGatewayId());
      int j = pdu.length() / 2;
      if (getSmscNumber() == null)
      {
        // Do nothing on purpose!
      }
View Full Code Here

Examples of org.ajwcc.pduUtils.gsm3040.Pdu

          try
          {
            Logger.getInstance().logDebug("READ PDU: " + pduString, null, getGatewayId());
            // this will throw an exception for PDUs
            // it can't classify
            Pdu pdu = parser.parsePdu(pduString);
            // NOTE: maybe a message validity vs the current
            //       date should be put here.
            //       if the message is invalid, the message should
            //       be ignored and but logged
            if (pdu instanceof SmsDeliveryPdu)
            {
              Logger.getInstance().logDebug(pdu.toString(), null, getGatewayId());
              InboundMessage msg;
              String memLocation = getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2);
              if (pdu.isBinary())
              {
                msg = new InboundBinaryMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
                if (Service.getInstance().getKeyManager().getKey(msg.getOriginator()) != null) msg = new InboundEncryptedMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
              }
              else
              {
                msg = new InboundMessage((SmsDeliveryPdu) pdu, memIndex, memLocation);
              }
              msg.setGatewayId(getGatewayId());
              Logger.getInstance().logDebug("IN-DTLS: MI:" + msg.getMemIndex() + " REF:" + msg.getMpRefNo() + " MAX:" + msg.getMpMaxNo() + " SEQ:" + msg.getMpSeqNo(), null, getGatewayId());
              if (msg.getMpRefNo() == 0)
              {
                // single message
                msgList.add(msg);
                incInboundMessageCount();
              }
              else
              {
                // multi-part message
                int k, l;
                List<InboundMessage> tmpList;
                InboundMessage listMsg;
                boolean found, duplicate;
                found = false;
                for (k = 0; k < this.mpMsgList.size(); k++)
                {
                  // List of List<InboundMessage>
                  tmpList = this.mpMsgList.get(k);
                  listMsg = tmpList.get(0);
                  // check if current message list is for this message
                  if (listMsg.getMpRefNo() == msg.getMpRefNo())
                  {
                    duplicate = false;
                    // check if the message is already in the message list
                    for (l = 0; l < tmpList.size(); l++)
                    {
                      listMsg = tmpList.get(l);
                      if (listMsg.getMpSeqNo() == msg.getMpSeqNo())
                      {
                        duplicate = true;
                        break;
                      }
                    }
                    if (!duplicate) tmpList.add(msg);
                    found = true;
                    break;
                  }
                }
                if (!found)
                {
                  // no existing list present for this message
                  // add one
                  tmpList = new ArrayList<InboundMessage>();
                  tmpList.add(msg);
                  this.mpMsgList.add(tmpList);
                }
              }
            }
            else if (pdu instanceof SmsStatusReportPdu)
            {
              StatusReportMessage msg;
              msg = new StatusReportMessage((SmsStatusReportPdu) pdu, memIndex, getATHandler().getStorageLocations().substring((ml * 2), (ml * 2) + 2));
              msg.setGatewayId(getGatewayId());
              msgList.add(msg);
              incInboundMessageCount();
            }
            else
            {
              // this theoretically will never happen, but it occasionally does with phones
              // like some Sony Ericssons (e.g. Z610i, SENT messages are included in this list)
              // instead of throwing a RuntimeException, just ignore any messages that are not of type
              // SmsDeliveryPdu
              // SmsStatusReportPdu
              if (this.displayIllegalReceivedMessages)
              {
                Logger.getInstance().logError("Wrong type of PDU detected: " + pdu.getClass().getName(), null, getGatewayId());
                Logger.getInstance().logError("ERROR PDU: " + pduString, null, getGatewayId());
              }
            }
          }
          catch (Exception e)
View Full Code Here

Examples of org.ajwcc.pduUtils.gsm3040.Pdu

    if ((pdu.hasTpUdhi()) && (getEncoding() == MessageEncodings.ENC7BIT)) { throw new RuntimeException("getPduUserData() not supported for 7-bit messages with UDH"); }
    // sum up the ud parts
    StringBuffer ud = new StringBuffer();
    for (String pduString : pdus)
    {
      Pdu newPdu = new PduParser().parsePdu(pduString);
      ud.append(PduUtils.bytesToPdu(newPdu.getUserDataAsBytes()));
    }
    return ud.toString();
  }
View Full Code Here

Examples of org.ajwcc.pduUtils.gsm3040.Pdu

    // NOTE: - the mpRefNo is arbitrarily set to 1
    // - if the user wishes to extract the UDH per part, he would need to get all pduStrings
    // using getPdus(String smscNumber, int mpRefNo), use a
    // PduParser on each pduString in the returned list, then access the UDH via the Pdu object
    List<String> pdus = pduGenerator.generatePduList(pdu, 1);
    Pdu newPdu = new PduParser().parsePdu(pdus.get(0));
    byte[] udh = newPdu.getUDHData();
    if (udh != null) return PduUtils.bytesToPdu(udh);
    return null;
  }
View Full Code Here

Examples of org.smpp.pdu.PDU

   */
  final protected PDU tryReceivePDUWithTimeout(Connection connection, PDU expectedPDU, long timeout)
    throws UnknownCommandIdException, TimeoutException, PDUException, IOException {
    debug.write(DRXTX, "receivePDU: Going to receive response.");
    long startTime = Data.getCurrentTime();
    PDU pdu = null;
    if (timeout == 0) {
      // with no timeout try just once
      pdu = tryReceivePDU(connection, expectedPDU);
    } else {
      // with timeout keep trying until get some or timeout expires
      while ((pdu == null) && canContinueReceiving(startTime, timeout)) {
        pdu = tryReceivePDU(connection, expectedPDU);
      }
    }
    if (pdu != null) {
      debug.write(DRXTX, "Got pdu " + pdu.debugString());
    }
    return pdu;
  }
View Full Code Here

Examples of org.smpp.pdu.PDU

   * @see Unprocessed
   */
  final protected PDU receivePDUFromConnection(Connection connection, Unprocessed unprocessed)
    throws UnknownCommandIdException, TimeoutException, PDUException, IOException {
    debug.write(DRXTXD2, "ReceiverBase.receivePDUFromConnection start");
    PDU pdu = null;
    ByteBuffer buffer;
    ByteBuffer unprocBuffer;
   
    try {
      // first check if there is something left from the last time
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.