GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jayji666/sms-client: 三网合一短信客户端,支持(cmpp/smpp3.4/sgip1.2/smgp3) 短信协议

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

47 Commits
47 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

技术问题请加QQ群

qq 20180420170449

群名称:cmppGate短信
群 号:770738500

一个基于SMSGate框架 的纯发送短信客户端库,使用简单

How To Use

<dependency>
  <groupId>com.chinamobile.cmos</groupId>
  <artifactId>sms-client</artifactId>
  <version>0.1</version>
</dependency>
  • 如何创建smsClient对象

    通过builder模式,为同一个账号创建唯一一个实例对象,不能重复创建。 smsClient对象创建后会自行管理多个tcp连接,如果重复创建Client对象,就会造成总连接数超过最大值。

  • 如何发送短信?

    参考test包里的测试用例 :

		String uri = "cmpp://127.0.0.1:17890?username=test01&password=1qaz2wsx&version=32&spcode=10086&msgsrc=test01&serviceid=000000&window=32&maxchannel=1";

		//通过builder创建一个Client对象,同一个通道账号只用保持一个smsClient实例。可以使用Spring注册为单例Bean。或者单例模式
		SmsClientBuilder builder = new SmsClientBuilder();
//		EndpointEntity client =  builder.createEndpointEntity(uri);
		final SmsClient smsClient = builder.uri(uri) // 保持空闲连接,以便能接收上行或者状态报告消息
				.receiver(new MessageReceiver() {
					public void receive(BaseMessage message) {
//						System.out.println(message.toString());
					}
				}).build();
				
		
		Future future = null;
		
		//发送5000条短信
		for (int i = 0; i < 1; i++) {
			 future = executor.submit(new Runnable() {

				public void run() {
					//new 一个短信 Request对象
					CmppSubmitRequestMessage msg = new CmppSubmitRequestMessage();
					msg.setDestterminalId(String.valueOf(13800138000));
					msg.setSrcId(String.valueOf(10699802323));
					msg.setLinkID("0000");
					msg.setMsgContent("老师好,Hello World");
					msg.setRegisteredDelivery((short) 1);
					msg.setServiceId("ssss");
					CmppSubmitResponseMessage response;
					try {
					//调用send方法发送
						response = (CmppSubmitResponseMessage) smsClient.send(msg);
						
						//收到Response消息
					} catch (Exception e) {
						logger.info("send ", e);
					}
				}
				
			});
		}
  • 如何发送长短信?

    默认已经处理好长短信了,就像发送普通短信一样。

  • 如何接收短信?

    参考test包里的测试用例 : 创建 Builder的时候注册 MessageReceiver类。

    SGIP协议是特例,因为该协议要求开启一个Server端口,网关作为客户端连上来推送上行短信和状态报告。

  • 使用 http 或者 socks 代理

    SmsGate支持HTTP、SOCKS代理以方便在使用代理访问服务器的情况。代理设置方式:

	// 无username 和 password 可写为  http://ipaddress:port
	client.setProxy("http://username:password@ipaddress:port");  //http代理
	client.setProxy("socks4://username:password@ipaddress:port");  //socks4代理
	client.setProxy("socks5://username:password@ipaddress:port");  //socks5代理

SGIP回收状态报告和用户回复

  • 为什么smsClient不提供sgip协议的接收上行消息、状态报告能力

    smsClient是一个tcp客户端,它需要主动去连接服务端的tcp端口。而sgip协议要求接收上行回复短信时,SP要启动一个tcp服务,等待来自运营商短信网关的连接请求(此时运营商是tcp客户端)。 一般系统部署时,作为客户端可能会部署多个进程节点,类似HTTP请求,可以从多个节点分别发起请求。

    但sgip的上行短信接收服务作为一个tcp服务端只能有一个,集成在client端很别扭。 替代方式为:根据系统架构特点,设计接收上行消息的tcp服务如何部署,比如可以独立一个节点,也可以与Http的web服务一起部署。 SgipServer的开发方式可以参考smsServer 。

About

三网合一短信客户端,支持(cmpp/smpp3.4/sgip1.2/smgp3) 短信协议

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.