本文整理了Java中com.cloudhopper.smpp.type.Address
类的一些代码示例,展示了Address
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address
类的具体详情如下:
包路径:com.cloudhopper.smpp.type.Address
类名称:Address
[英]Simple representation of an Address in SMPP.
[中]SMPP中地址的简单表示。
代码示例来源:origin: traccar/traccar
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) {
代码示例来源:origin: traccar/traccar
@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;
}
代码示例来源:origin: twitter-archive/cloudhopper-smpp
/**
* Read and create a new Address from a buffer. Checks if there is
* a minimum number of bytes readable from the buffer.
* @param buffer
* @return
* @throws UnrecoverablePduEncodingException
* @throws RecoverablePduEncodingException
*/
static public Address readAddress(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException {
// an address is at least 3 bytes long (ton, npi, and null byte)
if (buffer.readableBytes() < 3) {
throw new NotEnoughDataInBufferException("Parsing address", buffer.readableBytes(), 3);
}
Address address = new Address();
address.read(buffer);
return address;
}
代码示例来源:origin: org.restcomm.smpp/smpp-extensions
String addressRange = esme.getEsmeAddressRange();
Address addressRangeObj = new Address();
if(addressTon!=-1){
addressRangeObj.setTon((byte)addressTon);
addressRangeObj.setNpi((byte)addressNpi);
addressRangeObj.setAddress(addressRange);
代码示例来源:origin: org.restcomm.smpp/smpp-extensions
public boolean isSourceAddressMatching(Address sourceAddress) {
// Check sourceTon
if (this.sourceTon != -1 && this.sourceTon != sourceAddress.getTon()) {
return false;
}
// Check sourceNpi
if (this.sourceNpi != -1 && this.sourceNpi != sourceAddress.getNpi()) {
return false;
}
// Check sourceAddress
Matcher m = this.sourceAddressRangePattern.matcher(sourceAddress.getAddress());
if (m.matches()) {
return true;
}
return false;
}
代码示例来源:origin: org.mobicents.smsc/smpp
if (esme.getEsmeTon() != -1 && esme.getEsmeTon() != bindRequestAddressRange.getTon()) {
logger.error(String.format("Received BIND request with TON=%d but configured TON=%d",
bindRequestAddressRange.getTon(), esme.getEsmeTon()));
throw new SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
if (esme.getEsmeNpi() != -1 && esme.getEsmeNpi() != bindRequestAddressRange.getNpi()) {
logger.error(String.format("Received BIND request with NPI=%d but configured NPI=%d",
bindRequestAddressRange.getNpi(), esme.getEsmeNpi()));
throw new SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
if (bindRequestAddressRange.getAddress() == null || bindRequestAddressRange.getAddress() == "") {
bindRequestAddressRange.setAddress(esme.getEsmeAddressRange());
} else if (!bindRequestAddressRange.getAddress().equals(esme.getEsmeAddressRange())) {
logger.error(String.format(
"Received BIND request with Address_Range=%s but configured Address_Range=%s",
bindRequestAddressRange.getAddress(), esme.getEsmeAddressRange()));
throw new SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
代码示例来源:origin: org.restcomm.smpp/ch-smpp
@Override
public String toString() {
StringBuilder buffer = new StringBuilder(44);
buffer.append(this.address.toString());
buffer.append(" errorStatusCode [");
buffer.append(this.errorStatusCode);
buffer.append("]");
return buffer.toString();
}
代码示例来源:origin: twitter-archive/cloudhopper-smpp
/**
* Calculates the byte size of an Address. Safe to call with nulls as a
* parameter since this will then just return the size of an empty address.
* @param value
* @return
*/
static public int calculateByteSizeOfAddress(Address value) {
if (value == null) {
return SmppConstants.EMPTY_ADDRESS.calculateByteSize();
} else {
return value.calculateByteSize();
}
}
代码示例来源:origin: com.fizzed/ch-smpp
/**
* Writes an address to a buffer. If the address is null, this method will
* safely write out the SmppConstants.EMPTY_ADDRESS instance.
* @param buffer
* @param value
* @throws UnrecoverablePduEncodingException
* @throws RecoverablePduEncodingException
*/
static public void writeAddress(ChannelBuffer buffer, Address value) throws UnrecoverablePduException, RecoverablePduException {
if (value == null) {
SmppConstants.EMPTY_ADDRESS.write(buffer);
} else {
value.write(buffer);
}
}
代码示例来源:origin: com.fizzed/ch-smpp
/**
* Read and create a new Address from a buffer. Checks if there is
* a minimum number of bytes readable from the buffer.
* @param buffer
* @return
* @throws UnrecoverablePduEncodingException
* @throws RecoverablePduEncodingException
*/
static public Address readAddress(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException {
// an address is at least 3 bytes long (ton, npi, and null byte)
if (buffer.readableBytes() < 3) {
throw new NotEnoughDataInBufferException("Parsing address", buffer.readableBytes(), 3);
}
Address address = new Address();
address.read(buffer);
return address;
}
代码示例来源:origin: org.mobicents.smsc/smpp
String addressRange = esme.getEsmeAddressRange();
Address addressRangeObj = new Address();
if(addressTon!=-1){
addressRangeObj.setTon((byte)addressTon);
addressRangeObj.setNpi((byte)addressNpi);
addressRangeObj.setAddress(addressRange);
代码示例来源:origin: org.mobicents.smsc/smpp
public boolean isSourceAddressMatching(Address sourceAddress) {
// Check sourceTon
if (this.sourceTon != -1 && this.sourceTon != sourceAddress.getTon()) {
return false;
}
// Check sourceNpi
if (this.sourceNpi != -1 && this.sourceNpi != sourceAddress.getNpi()) {
return false;
}
// Check sourceAddress
Matcher m = this.sourceAddressRangePattern.matcher(sourceAddress.getAddress());
if (m.matches()) {
return true;
}
return false;
}
代码示例来源:origin: org.restcomm.smpp/smpp-extensions
if (esme.getEsmeTon() != -1 && esme.getEsmeTon() != bindRequestAddressRange.getTon()) {
logger.error(String.format("Received BIND request with TON=%d but configured TON=%d",
bindRequestAddressRange.getTon(), esme.getEsmeTon()));
throw new SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
if (esme.getEsmeNpi() != -1 && esme.getEsmeNpi() != bindRequestAddressRange.getNpi()) {
logger.error(String.format("Received BIND request with NPI=%d but configured NPI=%d",
bindRequestAddressRange.getNpi(), esme.getEsmeNpi()));
throw new SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
if (bindRequestAddressRange.getAddress() == null || bindRequestAddressRange.getAddress() == "") {
bindRequestAddressRange.setAddress(esme.getEsmeAddressRange());
} else if (!bindRequestAddressRange.getAddress().equals(esme.getEsmeAddressRange())) {
logger.error(String.format(
"Received BIND request with Address_Range=%s but configured Address_Range=%s",
bindRequestAddressRange.getAddress(), esme.getEsmeAddressRange()));
throw new SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
代码示例来源:origin: com.fizzed/ch-smpp
@Override
public void appendBodyToString(StringBuilder buffer) {
buffer.append("systemId [");
buffer.append(StringUtil.toStringWithNullAsEmpty(this.systemId));
buffer.append("] password [");
buffer.append(StringUtil.toStringWithNullAsEmpty(this.password));
buffer.append("] systemType [");
buffer.append(StringUtil.toStringWithNullAsEmpty(this.systemType));
buffer.append("] interfaceVersion [0x");
buffer.append(HexUtil.toHexString(this.interfaceVersion));
buffer.append("] addressRange (");
if (this.addressRange == null) {
buffer.append(SmppConstants.EMPTY_ADDRESS.toString());
} else {
buffer.append(StringUtil.toStringWithNullAsEmpty(this.addressRange));
}
buffer.append(")");
}
}
代码示例来源:origin: com.fizzed/ch-smpp
/**
* Calculates the byte size of an Address. Safe to call with nulls as a
* parameter since this will then just return the size of an empty address.
* @param value
* @return
*/
static public int calculateByteSizeOfAddress(Address value) {
if (value == null) {
return SmppConstants.EMPTY_ADDRESS.calculateByteSize();
} else {
return value.calculateByteSize();
}
}
代码示例来源:origin: twitter-archive/cloudhopper-smpp
/**
* Writes an address to a buffer. If the address is null, this method will
* safely write out the SmppConstants.EMPTY_ADDRESS instance.
* @param buffer
* @param value
* @throws UnrecoverablePduEncodingException
* @throws RecoverablePduEncodingException
*/
static public void writeAddress(ChannelBuffer buffer, Address value) throws UnrecoverablePduException, RecoverablePduException {
if (value == null) {
SmppConstants.EMPTY_ADDRESS.write(buffer);
} else {
value.write(buffer);
}
}
代码示例来源:origin: MavoCz/smscsim
@Override
public DeliverSm createMessage() throws Exception {
Address sourceAddress = new Address((byte) sourceAddressTon, (byte) sourceAddressNpi, sourceAddressDigits);
Address destinationAddress = new Address((byte) destAddressTon, (byte) destAddressNpi, destAddressDigits);
DeliverSm pdu = SmppPduUtils.createDeliverSm(sourceAddress, destinationAddress, sessionManager.getNextSequenceNumber());
return pdu;
}
代码示例来源:origin: org.restcomm.smpp/ch-smpp
/**
* Read and create a new Address from a buffer. Checks if there is
* a minimum number of bytes readable from the buffer.
* @param buffer
* @return
* @throws UnrecoverablePduEncodingException
* @throws RecoverablePduEncodingException
*/
static public Address readAddress(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException {
// an address is at least 3 bytes long (ton, npi, and null byte)
if (buffer.readableBytes() < 3) {
throw new NotEnoughDataInBufferException("Parsing address", buffer.readableBytes(), 3);
}
Address address = new Address();
address.read(buffer);
return address;
}
代码示例来源:origin: org.mobicents.smsc/smpp-server-ra-ra
tracer.warning(String
.format("Incoming SUBMIT_SM's sequence_number=%d source_addr_ton=%d source_addr_npi=%d source_addr=%s doesn't match with configured ESME name=%s source_addr_ton=%d source_addr_npi=%d source_addr=%s",
submitSm.getSequenceNumber(), sourceAddress.getTon(), sourceAddress.getNpi(),
sourceAddress.getAddress(), this.esme.getName(), this.esme.getSourceTon(),
this.esme.getSourceNpi(), this.esme.getSourceAddressRange()));
tracer.warning(String
.format("Incoming DATA_SM's sequence_number=%d source_addr_ton=%d source_addr_npi=%d source_addr=%s doesn't match with configured ESME name=%s source_addr_ton=%d source_addr_npi=%d source_addr=%s",
dataSm.getSequenceNumber(), sourceAddress.getTon(), sourceAddress.getNpi(),
sourceAddress.getAddress(), this.esme.getName(), this.esme.getSourceTon(),
this.esme.getSourceNpi(), this.esme.getSourceAddressRange()));
tracer.warning(String
.format("Incoming DELIVER_SM's sequence_number=%d source_addr_ton=%d source_addr_npi=%d source_addr=%s doesn't match with configured ESME name=%s source_addr_ton=%d source_addr_npi=%d source_addr=%s",
deliverSm.getSequenceNumber(), sourceAddress.getTon(), sourceAddress.getNpi(),
sourceAddress.getAddress(), this.esme.getName(), this.esme.getSourceTon(),
this.esme.getSourceNpi(), this.esme.getSourceAddressRange()));
tracer.warning(String
.format("Incoming SUBMIT_MULTI's sequence_number=%d source_addr_ton=%d source_addr_npi=%d source_addr=%s doesn't match with configured ESME name=%s source_addr_ton=%d source_addr_npi=%d source_addr=%s",
submitMulti.getSequenceNumber(), sourceAddress.getTon(), sourceAddress.getNpi(),
sourceAddress.getAddress(), this.esme.getName(), this.esme.getSourceTon(),
this.esme.getSourceNpi(), this.esme.getSourceAddressRange()));
代码示例来源:origin: twitter-archive/cloudhopper-smpp
@Override
public void appendBodyToString(StringBuilder buffer) {
buffer.append("systemId [");
buffer.append(StringUtil.toStringWithNullAsEmpty(this.systemId));
buffer.append("] password [");
buffer.append(StringUtil.toStringWithNullAsEmpty(this.password));
buffer.append("] systemType [");
buffer.append(StringUtil.toStringWithNullAsEmpty(this.systemType));
buffer.append("] interfaceVersion [0x");
buffer.append(HexUtil.toHexString(this.interfaceVersion));
buffer.append("] addressRange (");
if (this.addressRange == null) {
buffer.append(SmppConstants.EMPTY_ADDRESS.toString());
} else {
buffer.append(StringUtil.toStringWithNullAsEmpty(this.addressRange));
}
buffer.append(")");
}
}
内容来源于网络,如有侵权,请联系作者删除!