当前位置: 首页 > news >正文

锡林浩特本地网站建设在线建筑设计

锡林浩特本地网站建设,在线建筑设计,庆云县建设局网站,wordpress鼠标烟花绽放的效果smpp客户端这篇文章通过创建一个简单的SMPP客户端向移动用户发送短信来提供SMPP Java示例#xff0c;使用该客户端我们可以简单地提交以将消息发送给单个移动用户#xff0c;也可以一次将消息广播给多个移动用户。另外#xff0c;我们将验证交货收据。 出于客户端的目的使用该客户端我们可以简单地提交以将消息发送给单个移动用户也可以一次将消息广播给多个移动用户。另外我们将验证交货收据。 出于客户端的目的我们将使用现有的Java SMPP客户端库– jSMPP 什么是SMPP SMPP代表短消息对等。 它是一种开放的行业标准协议旨在为短消息数据的传输提供灵活的数据通信接口。大多数时候SMPP用于批量传送短消息您可以一次将消息广播给数千个订户。不仅限于短消息我们还可以携带语音邮件通知小区广播WAP消息包括WAP Push消息 SMPP操作 SMPP使用客户机/服务器操作模型。在向SMPP提交任何消息之前我们发送一个bind命令。 在此示例中我们将发送bind_transmitter因为我们仅对向服务器提交消息感兴趣。 除了bind_transmitter以外其他bind命令是bind_receiver这意味着客户端将仅接收消息bind_transceiver允许双向传输消息。 SMPP操作的完整细节不在本文讨论范围之内。 如果您想详细了解操作请访问– SMPP Wiki 使用jSMPP 要开始使用SMPP客户端我们将使用jSMPP。 要将jSMPP包含在您的项目中请将以下maven依赖项添加到pom.xml中 pom.xml dependencygroupIdorg.jsmpp/groupIdartifactIdjsmpp/artifactIdversion2.3.5/version /dependencySMPP多次提交示例 正如我们讨论的那样SMPP可用于向单个或多个订户发送消息。以下是向多个移动订户发送消息的示例。第一步是使用主机名用户名和密码向服务器发送绑定命令。 我们正在initSession中执行此操作。 完成此操作后将创建SMPP会话然后我们可以使用此会话发送消息。 相应的提供程序将提供不同的参数例如ip主机用户名密码。 MultipleSubmitExample.java public class MultipleSubmitExample {private static final Logger LOGGER LoggerFactory.getLogger(MultipleSubmitExample.class);private static final TimeFormatter TIME_FORMATTER new AbsoluteTimeFormatter();private final String smppIp 127.0.0.1;private int port 8086;private final String username localhost;private final String password password;private final String address AX-DEV;private static final String SERVICE_TYPE CMT;public void broadcastMessage(String message, List numbers) {LOGGER.info(Broadcasting sms);SubmitMultiResult result null;Address[] addresses prepareAddress(numbers);SMPPSession session initSession();if(session ! null) {try {result session.submitMultiple(SERVICE_TYPE, TypeOfNumber.NATIONAL, NumberingPlanIndicator.UNKNOWN, address,addresses, new ESMClass(), (byte) 0, (byte) 1, TIME_FORMATTER.format(new Date()), null,new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE), ReplaceIfPresentFlag.REPLACE,new GeneralDataCoding(Alphabet.ALPHA_DEFAULT, MessageClass.CLASS1, false), (byte) 0,message.getBytes());LOGGER.info(Messages submitted, result is {}, result);Thread.sleep(1000);} catch (PDUException e) {LOGGER.error(Invalid PDU parameter, e);} catch (ResponseTimeoutException e) {LOGGER.error(Response timeout, e);} catch (InvalidResponseException e) {LOGGER.error(Receive invalid response, e);} catch (NegativeResponseException e) {LOGGER.error(Receive negative response, e);} catch (IOException e) {LOGGER.error(I/O error occured, e);} catch (Exception e) {LOGGER.error(Exception occured submitting SMPP request, e);}}else {LOGGER.error(Session creation failed with SMPP broker.);}if(result ! null result.getUnsuccessDeliveries() ! null result.getUnsuccessDeliveries().length 0) {LOGGER.error(DeliveryReceiptState.getDescription(result.getUnsuccessDeliveries()[0].getErrorStatusCode()).description() - result.getMessageId());}else {LOGGER.info(Pushed message to broker successfully);}if(session ! null) {session.unbindAndClose();}}private Address[] prepareAddress(List numbers) {Address[] addresses new Address[numbers.size()];for(int i 0; i numbers.size(); i){addresses[i] new Address(TypeOfNumber.NATIONAL, NumberingPlanIndicator.UNKNOWN, numbers.get(i));}return addresses;}private SMPPSession initSession() {SMPPSession session new SMPPSession();try {session.setMessageReceiverListener(new MessageReceiverListenerImpl());String systemId session.connectAndBind(smppIp, Integer.valueOf(port), new BindParameter(BindType.BIND_TX, username, password, cp, TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null));LOGGER.info(Connected with SMPP with system id {}, systemId);} catch (IOException e) {LOGGER.error(I/O error occured, e);session null;}return session;}public static void main(String[] args) {MultipleSubmitExample multiSubmit new MultipleSubmitExample();multiSubmit.broadcastMessage(Test message from devglan, Arrays.asList(9513059515, 8884377251));} } 在创建SMPP会话时我们已经注册了消息接收方侦听器该侦听器将用于获取消息的传递收据。 以下是示例。 MessageReceiverListenerImpl.java public class MessageReceiverListenerImpl implements MessageReceiverListener {private static final Logger LOGGER LoggerFactory.getLogger(MessageReceiverListenerImpl.class);private static final String DATASM_NOT_IMPLEMENTED data_sm not implemented;public void onAcceptDeliverSm(DeliverSm deliverSm) throws ProcessRequestException {if (MessageType.SMSC_DEL_RECEIPT.containedIn(deliverSm.getEsmClass())) {try {DeliveryReceipt delReceipt deliverSm.getShortMessageAsDeliveryReceipt();long id Long.parseLong(delReceipt.getId()) 0xffffffff;String messageId Long.toString(id, 16).toUpperCase();LOGGER.info(Receiving delivery receipt for message {} from {} to {}: {},messageId, deliverSm.getSourceAddr(), deliverSm.getDestAddress(), delReceipt);} catch (InvalidDeliveryReceiptException e) {LOGGER.error(Failed getting delivery receipt, e);}}}public void onAcceptAlertNotification(AlertNotification alertNotification) {LOGGER.info(AlertNotification not implemented);}public DataSmResult onAcceptDataSm(DataSm dataSm, Session source)throws ProcessRequestException {LOGGER.info(DataSm not implemented);throw new ProcessRequestException(DATASM_NOT_IMPLEMENTED, SMPPConstant.STAT_ESME_RINVCMDID);} }SMPP交货收据 SMPP提供了许多标准的交货收据错误代码来标识交货收据。 我们几乎没有采取任何措施来识别实际的收货信息。有关完整的详尽清单请遵循– smpperrorcodes DeliveryReceiptState.java package com.devglan.smpp;public enum DeliveryReceiptState {ESME_ROK(0, Ok - Message Acceptable),ESME_RINVMSGLEN(1, Invalid Message Length),ESME_RINVCMDLEN(2, Invalid Command Length),ESME_RINVCMDID(3, Invalid Command ID),ESME_RINVBNDSTS(4, Invalid bind status),ESME_RALYBND(5, Bind attempted when already bound),ESME_RINVPRTFLG(6, Invalid priority flag),ESME_RINVREGDLVFLG(7, Invalid registered-delivery flag),ESME_RSYSERR(8, SMSC system error),ESME_RINVSRCADR(9, Invalid source address),ESME_RINVDSTADR(11, Invalid destination address),ESME_RINVMSGID(12, Invalid message-id),NOT_FOUND(000, Couldnt resolve.Ask admin to add.);private int value;private String description;DeliveryReceiptState(int value, String description) {this.value value;this.description description;}public static DeliveryReceiptState getDescription(int value) {for (DeliveryReceiptState item : values()) {if (item.value() value) {return item;}}return NOT_FOUND;}public int value() {return value;}public String description() {return description;}}SMPP单一提交示例 jSMPP为单个提交提供了commitShortMessage。以下是实现。 源代码中提供了完整的实现。 String messageId session.submitShortMessage(SERVICE_TYPE,TypeOfNumber.NATIONAL, NumberingPlanIndicator.UNKNOWN, address,TypeOfNumber.NATIONAL, NumberingPlanIndicator.UNKNOWN, number,new ESMClass(), (byte)0, (byte)1, TIME_FORMATTER.format(new Date()), null,new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE), (byte)0, new GeneralDataCoding(Alphabet.ALPHA_DEFAULT, MessageClass.CLASS1, false), (byte)0,message.getBytes());结论 这是Java中SMPP客户端实现的简单示例。 在下一篇文章中我们将讨论其模拟器。 翻译自: https://www.javacodegeeks.com/2018/03/smpp-java-exampleclient.htmlsmpp客户端
http://www.yutouwan.com/news/419661/

相关文章:

  • 上海松江 网站建设公司网络营销推广方式怎么收费
  • 网站和公众号的区别是什么意思wordpress 排版
  • 株洲市建设局网站如何用手机免费开网店
  • 陕西网站建设方案优化凡科网可以自己做网站吗
  • 温州网站改版哪家好做网站都需要什么资料
  • 成都市建设厅网站wp网站建设模板
  • 搜索引擎作弊网站有哪些wordpress中文版广告
  • 选择seo网站排名优化聊城住房和城乡建设部网站
  • 企业网站营销的优缺点坡头手机网站建设
  • 网站访客抓取系统微信营销的优势有哪些
  • 网站历史权重查询网站索引量
  • wamp可以做视频网站吗厦门广告公司排行榜
  • 做php网站用mvc多吗中小企业网站建设维护内容
  • php网站建设网站联通屏蔽wordpress
  • 电视云网站建设北京网站开发哪里好薇
  • 企业网站备案备注在线制作名片
  • c2c电商平台网站可克达拉市建设局网站
  • 怎么做熊掌号网站图书租借网站 开发
  • 刷网站关键词工具网站建设绵阳辉煌电商
  • 网站建设一般一年多少费用网站制作视频教程免费
  • 做网站和做小程序有什么不同友情链接的网站图片
  • 中小型企业网站的设计与开发个人网站做废品回收
  • 如何评判一个网站建设的怎么样关闭wordpress注册邮件
  • 有做电动车修车的网站吗简单网站建设课程
  • jsp网站如何做seo大学课程免费自学网站
  • 怎么制作网站网页个人社保缴费证明
  • 网站开发需要哪些能力做网站百度收录
  • 房地产网页设计网站建设网站建设的目的及功能定位
  • 国外可以做推广的网站吗在线优化网站建设
  • wordpress 站外链接宿州大型网站建设公司