當前位置: 首頁>>代碼示例>>Java>>正文


Java SubmitSmResp類代碼示例

本文整理匯總了Java中com.cloudhopper.smpp.pdu.SubmitSmResp的典型用法代碼示例。如果您正苦於以下問題:Java SubmitSmResp類的具體用法?Java SubmitSmResp怎麽用?Java SubmitSmResp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SubmitSmResp類屬於com.cloudhopper.smpp.pdu包,在下文中一共展示了SubmitSmResp類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendMessageSync

import com.cloudhopper.smpp.pdu.SubmitSmResp; //導入依賴的package包/類
public synchronized void sendMessageSync(String destAddress, String message, boolean command)
        throws RecoverablePduException, UnrecoverablePduException, SmppTimeoutException, SmppChannelException,
        InterruptedException, IllegalStateException {
    if (getSession() != null && getSession().isBound()) {
        SubmitSm submit = new SubmitSm();
        byte[] textBytes;
        textBytes = CharsetUtil.encode(message, command ? commandsCharsetName : notificationsCharsetName);
        submit.setDataCoding(command ? commandsDataCoding : notificationsDataCoding);
        submit.setShortMessage(textBytes);
        submit.setSourceAddress(command ? new Address(commandSourceTon, commandSourceNpi, commandSourceAddress)
                : new Address(sourceTon, sourceNpi, sourceAddress));
        submit.setDestAddress(new Address(destTon, destNpi, destAddress));
        SubmitSmResp submitResponce = getSession().submit(submit, submitTimeout);
        if (submitResponce.getCommandStatus() == SmppConstants.STATUS_OK) {
            Log.debug("SMS submitted, message id: " + submitResponce.getMessageId());
        } else {
            throw new IllegalStateException(submitResponce.getResultMessage());
        }
    } else {
        throw new SmppChannelException("SMPP session is not connected");
    }
}
 
開發者ID:bamartinezd,項目名稱:traccar-service,代碼行數:23,代碼來源:SmppClient.java

示例2: firePduRequestReceived

import com.cloudhopper.smpp.pdu.SubmitSmResp; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
@Override
public PduResponse firePduRequestReceived(PduRequest pduRequest) {
    SmppSession session = sessionRef.get();

    if (pduRequest instanceof SubmitSm) {
        SubmitSm submitSm = (SubmitSm) pduRequest;
        SubmitSmResp submitSmResp = submitSm.createResponse();
        long messageId = messageIdGenerator.getNextMessageId();
        submitSmResp.setMessageId(FormatUtils.formatAsHex(messageId));
        try {
            // We can not wait in this thread!!
            // It would block handling of other messages and performance would drop drastically!!
            // create and enqueue delivery receipt
            if (submitSm.getRegisteredDelivery() > 0 && deliverSender != null) {
                DeliveryReceiptRecord record = new DeliveryReceiptRecord(session, submitSm, messageId);
                record.setDeliverTime(deliveryReceiptScheduler.getDeliveryTimeMillis());
                deliverSender.scheduleDelivery(record);
            }
        } catch (Exception e) {
            logger.error("Error when handling submit", e);
        }

        //submitSmResp.setCommandStatus(SmppConstants.STATUS_X_T_APPN);
        return submitSmResp;
        //return null;
    } else if (pduRequest instanceof Unbind) {
        //session.destroy();  
        // TO DO refine, this throws exceptions
        session.unbind(1000);
        return pduRequest.createResponse();
    }

    return pduRequest.createResponse();
}
 
開發者ID:MavoCz,項目名稱:smscsim,代碼行數:36,代碼來源:SmscSmppSessionHandler.java

示例3: handle

import com.cloudhopper.smpp.pdu.SubmitSmResp; //導入依賴的package包/類
@Override
    public void handle(Message<JsonObject> jsonObjectMessage) {
        logger.debug("Got: " + jsonObjectMessage);
        if (preservingSessionHandler.getSession() == null) {
            sendError(jsonObjectMessage, "Session is not available");
        } else {
            try {
                JsonObject object = jsonObjectMessage.body();
                byte[] textBytes = object.getBinary("textBytes");
                if (textBytes == null) {
                    textBytes = CharsetUtil.encode(object.getString("textString"), charset);
                }
                SubmitSm submit = new SubmitSm();
                //submit.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED);
                byte sourceTon = getOptionalByte(object, "sourceTon", (byte) 0x03);
                byte sourceNpi = getOptionalByte(object, "sourceNpi", (byte) 0x00);
                byte destTon = getOptionalByte(object, "destTon", (byte) 0x01);
                byte destNpi = getOptionalByte(object, "destNpi", (byte) 0x01);

                submit.setSourceAddress(new Address(sourceTon, sourceNpi, object.getString("source")));
                submit.setDestAddress(new Address(destTon, destNpi, object.getString("destination")));
                submit.setShortMessage(textBytes);
                submit.setReferenceObject(jsonObjectMessage);

                switch (mode) {
                    case ASYNC:
//                        WindowFuture<Integer, PduRequest, PduResponse> future = preservingSessionHandler.getSession().sendRequestPdu(submit, object.getLong("timeoutMillis", 10000), false);
//                        long start = System.currentTimeMillis();
                        preservingSessionHandler.getSession().sendRequestPdu(submit, object.getLong("timeoutMillis", 10000), false);
//                        logger.info("time: " + (System.currentTimeMillis() - start));
                        break;
                    case SYNC:
//                        start = System.currentTimeMillis();
                        SubmitSmResp resp = preservingSessionHandler.getSession().submit(submit, object.getLong("timeoutMillis", 10000));
//                        logger.info("time: " + (System.currentTimeMillis() - start));
                        if (resp.getCommandStatus() == 0) {
                            sendOK(jsonObjectMessage);
                        } else {
                            sendError(jsonObjectMessage, resp.getResultMessage());
                        }
                        break;
                    default:
                        break;
                }
            } catch (RecoverablePduException | InterruptedException | SmppChannelException | UnrecoverablePduException | SmppTimeoutException | RuntimeException e) {
                logger.error(e.getMessage(), e);
                sendError(jsonObjectMessage, e.getMessage(), e);
            }
        }
    }
 
開發者ID:ialexandrakis,項目名稱:vertx-mod-smpp-client,代碼行數:51,代碼來源:SmppClient.java


注:本文中的com.cloudhopper.smpp.pdu.SubmitSmResp類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。