本文整理汇总了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");
}
}
示例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();
}
示例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);
}
}
}