@Override public PduResponse firePduRequestReceived(PduRequest request) { PduResponse response; try { if (request instanceof DeliverSm) { String sourceAddress = ((DeliverSm) request).getSourceAddress().getAddress(); String message = CharsetUtil.decode(((DeliverSm) request).getShortMessage(), smppClient.mapDataCodingToCharset(((DeliverSm) request).getDataCoding())); LOGGER.info("SMS Message Received: " + message.trim() + ", Source Address: " + sourceAddress); boolean isDeliveryReceipt; if (smppClient.getDetectDlrByOpts()) { isDeliveryReceipt = request.getOptionalParameters() != null; } else { isDeliveryReceipt = SmppUtil.isMessageTypeAnyDeliveryReceipt(((DeliverSm) request).getEsmClass()); } if (!isDeliveryReceipt) { TextMessageEventHandler.handleTextMessage(sourceAddress, message); } } response = request.createResponse(); } catch (Exception error) { LOGGER.warn("SMS receiving error", error); response = request.createResponse(); response.setResultMessage(error.getMessage()); response.setCommandStatus(SmppConstants.STATUS_UNKNOWNERR); } return response; }
@Override public void readBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { // the body may or may not contain a messageId -- the helper utility // method will take care of returning null if there aren't any readable bytes this.messageId = ChannelBufferUtil.readNullTerminatedString(buffer); }
@Override public void writeBody( ChannelBuffer buffer ) throws UnrecoverablePduException, RecoverablePduException{ ChannelBufferUtil.writeAddress(buffer, this.sourceAddress); ChannelBufferUtil.writeAddress(buffer, this.esmeAddress); }
@Override public int calculateByteSizeOfBody() { int bodyLength = 0; bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.serviceType); bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.messageId); bodyLength += PduUtil.calculateByteSizeOfAddress(this.sourceAddress); bodyLength += PduUtil.calculateByteSizeOfAddress(this.destAddress); return bodyLength; }
@Override public void writeBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { ChannelBufferUtil.writeNullTerminatedString(buffer, this.messageId); ChannelBufferUtil.writeAddress(buffer, this.sourceAddress); }
@Override public void readBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { this.serviceType = ChannelBufferUtil.readNullTerminatedString(buffer); this.messageId = ChannelBufferUtil.readNullTerminatedString(buffer); this.sourceAddress = ChannelBufferUtil.readAddress(buffer); this.destAddress = ChannelBufferUtil.readAddress(buffer); }
/** * Creates a new default SmppServer. Window monitoring and automatic * expiration of requests will be disabled with no monitorExecutors. * A "cachedDaemonThreadPool" will be used for IO worker threads. * @param configuration The server configuration to create this server with * @param serverHandler The handler implementation for handling bind requests * and creating/destroying sessions. */ public DefaultSmppServer(SmppServerConfiguration configuration, SmppServerHandler serverHandler) { this(configuration, serverHandler, DaemonExecutors.newCachedDaemonThreadPool()); }
@Override public int calculateByteSizeOfBody() { int bodyLength = 0; bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.messageId); return bodyLength; }
@Override protected int calculateByteSizeOfBody(){ int bodyLength = 0; bodyLength += PduUtil.calculateByteSizeOfAddress(this.sourceAddress); bodyLength += PduUtil.calculateByteSizeOfAddress(this.esmeAddress); return bodyLength; }
public DefaultSmppSessionCounters() { this.txSubmitSM = new ConcurrentCommandCounter(); this.txDeliverSM = new ConcurrentCommandCounter(); this.txEnquireLink = new ConcurrentCommandCounter(); this.txDataSM = new ConcurrentCommandCounter(); this.rxSubmitSM = new ConcurrentCommandCounter(); this.rxDeliverSM = new ConcurrentCommandCounter(); this.rxEnquireLink = new ConcurrentCommandCounter(); this.rxDataSM = new ConcurrentCommandCounter(); }
@Override public void readBody( ChannelBuffer buffer ) throws UnrecoverablePduException, RecoverablePduException{ this.sourceAddress = ChannelBufferUtil.readAddress(buffer); this.esmeAddress = ChannelBufferUtil.readAddress(buffer); }
public DeliveryReceipt(String messageId, int submitCount, int deliveredCount, DateTime submitDate, DateTime doneDate, byte state, int errorCode, String text) { this.messageId = messageId; this.submitCount = submitCount; this.deliveredCount = deliveredCount; this.submitDate = submitDate; this.doneDate = doneDate; this.state = state; setErrorCode(errorCode); this.text = text; }
@Override public int calculateByteSizeOfBody() { int bodyLength = 0; bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.systemId); bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.password); bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.systemType); bodyLength += 1; // interface version bodyLength += PduUtil.calculateByteSizeOfAddress(this.addressRange); return bodyLength; }
@Override public void writeBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { ChannelBufferUtil.writeNullTerminatedString(buffer, this.serviceType); ChannelBufferUtil.writeNullTerminatedString(buffer, this.messageId); ChannelBufferUtil.writeAddress(buffer, this.sourceAddress); ChannelBufferUtil.writeAddress(buffer, this.destAddress); }
@Override public void readBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { this.messageId = ChannelBufferUtil.readNullTerminatedString(buffer); this.sourceAddress = ChannelBufferUtil.readAddress(buffer); }
/** * Creates a new default SmppClient. Window monitoring and automatic * expiration of requests will be disabled with no monitorExecutors. * The maximum number of IO worker threads across any client sessions * created with this SmppClient will be Runtime.getRuntime().availableProcessors(). * An Executors.newCachedDaemonThreadPool will be used for IO worker threads. */ public DefaultSmppClient() { this(DaemonExecutors.newCachedDaemonThreadPool()); }
@Override public void readBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { // the body may or may not contain a systemId -- the helper utility // method will take care of returning null if there aren't any readable bytes this.systemId = ChannelBufferUtil.readNullTerminatedString(buffer); }
@Override public int calculateByteSizeOfBody() { int bodyLength = 0; bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.systemId); return bodyLength; }
@Override public int calculateByteSizeOfBody() { int bodyLength = 0; bodyLength += PduUtil.calculateByteSizeOfNullTerminatedString(this.serviceType); bodyLength += PduUtil.calculateByteSizeOfAddress(this.sourceAddress); bodyLength += PduUtil.calculateByteSizeOfAddress(this.destAddress); bodyLength += 3; // esmClass, regDelivery, dataCoding bytes return bodyLength; }