package ie.omk.smpp;
import ie.omk.smpp.event.ConnectionObserver;
import ie.omk.smpp.event.EventDispatcher;
import ie.omk.smpp.event.ReceiverExceptionEvent;
import ie.omk.smpp.event.ReceiverExitEvent;
import ie.omk.smpp.event.ReceiverStartEvent;
import ie.omk.smpp.event.SMPPEvent;
import ie.omk.smpp.event.SimpleEventDispatcher;
import ie.omk.smpp.message.Bind;
import ie.omk.smpp.message.BindResp;
import ie.omk.smpp.message.DeliverSM;
import ie.omk.smpp.message.DeliverSMResp;
import ie.omk.smpp.message.EnquireLink;
import ie.omk.smpp.message.EnquireLinkResp;
import ie.omk.smpp.message.InvalidParameterValueException;
import ie.omk.smpp.message.SMPPPacket;
import ie.omk.smpp.message.SMPPProtocolException;
import ie.omk.smpp.message.SMPPRequest;
import ie.omk.smpp.message.SMPPResponse;
import ie.omk.smpp.message.Unbind;
import ie.omk.smpp.message.UnbindResp;
import ie.omk.smpp.message.tlv.Tag;
import ie.omk.smpp.net.SmscLink;
import ie.omk.smpp.net.TcpLink;
import ie.omk.smpp.util.APIConfig;
import ie.omk.smpp.util.AlphabetEncoding;
import ie.omk.smpp.util.DefaultSequenceScheme;
import ie.omk.smpp.util.PacketFactory;
import ie.omk.smpp.util.PropertyNotFoundException;
import ie.omk.smpp.util.SMPPIO;
import ie.omk.smpp.util.SequenceNumberScheme;
import ie.omk.smpp.version.SMPPVersion;
import ie.omk.smpp.version.VersionException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* SMPP client connection (ESME). An SMPP Connection represents any kind of
* connection to the SMSC, be it a transmitter, receiver or transceiver. It also
* supports both synchronous and asynchronous modes of communication.
* Synchronous mode is only useful for very simple applications that use
* single-threading. Asynchronous mode is recommended for more complex
* applications, especially those that will be running many threads.
* <p>
* <b>Important Note </b>: if you wish to use synchronous mode in a
* multi-threaded environment, it is the <u>application's </u> responsiblity to
* ensure there is only one thread executing a call to either or both of the
* <code>sendRequest</code> and <code>readNextPacket</code> methods. If
* there are concurrent calls to these methods executing, there is a strong
* possibility of the incorrect packet being returned in a particular thread and
* both the API and the application getting confused. These are the only methods
* that contain such a race condition.
* </p>
*
* @author Oran Kelly
* @version $Id: Connection.java 302 2006-08-10 20:36:40Z orank $
*/
public class Connection implements java.lang.Runnable {
/** SMPP Transmitter connection type. */
public static final int TRANSMITTER = 1;
/** SMPP Receiver connection type. */
public static final int RECEIVER = 2;
/** SMPP Transciever connection type. */
public static final int TRANSCEIVER = 3;
/** Connection state: not bound to the SMSC. */
public static final int UNBOUND = 0;
/**
* Connection state: waiting for successful acknowledgement to bind request.
*/
public static final int BINDING = 1;
/** Connection state: bound to the SMSC. */
public static final int BOUND = 2;
/**
* Connection state: waiting for successful acknowledgement to unbind
* request or waiting for application to respond to unbind request.
*/
public static final int UNBINDING = 3;
private static final Log LOGGER = LogFactory.getLog(Connection.class);
/** Type of this SMPP connection. */
private int connectionType;
/** Packet listener thread for Asyncronous comms. */
private Thread rcvThread;
/**
* Queue of incoming packets to deliver to application before reading from
* the network. The queue is used only in syncrhonized mode. In the case
* where an application has sent a request to the SMSC and is blocked
* waiting a response and the SMSC initiates a request of it's own (an
* unbind request or an enquire_link), the API will cache the request packet
* and wait for the response to it's packet. Any other type of packet will
* be added to the packetQueue and subsequent calls to
* <code>readNextPacket</code> will clear this queue.
*/
private List packetQueue;
/**
* Object used to notify observers of SMPP events.
*/
private EventDispatcher eventDispatcher;
/** Byte buffer used in readNextPacketInternal. */
private byte[] buf = new byte[300];
/** Sequence numbering scheme to use for this connection. */
private SequenceNumberScheme seqNumScheme = new DefaultSequenceScheme();
/** The network link (virtual circuit) to the SMSC */
private SmscLink link;
/**
* SMPP protocol version number.
*/
protected SMPPVersion interfaceVersion = SMPPVersion.getDefaultVersion();
/**
* Does the remote end support optional parameters? According to the
* SMPPv3.4 specification, if the SMSC does not return the
* sc_interface_version optional parameter in its bind response packet, then
* we must assume it does not support optional parameters.
*/
protected boolean supportOptionalParams = true;
/**
* Current state of the SMPP connection. Possible states are UNBOUND,
* BINDING, BOUND and UNBINDING.
*/
private transient int state = UNBOUND;
/**
* Specify whether the listener thread will automatically ack enquire_link
* primitives received from the Smsc
*/
protected boolean ackQryLinks = true;
/**
* Automatically acknowledge incoming deliver_sm messages. Only valid for
* the Receiver
*/
protected boolean ackDeliverSm;
/** Is the user using synchronous are async communication?. */
protected boolean asyncComms;
/**
* The default alphabet to use for this connection.
*/
protected AlphabetEncoding defaultAlphabet;
/**
* Initialise a new SMPP connection object. This is a convenience
* constructor that will create a new {@link ie.omk.smpp.net.TcpLink}object
* using the host name and port provided. The connection created will use
* synchronous communications.
*
* @param host
* the hostname of the SMSC.
* @param port
* the port to connect to. If 0, use the default SMPP port
* number.
*/
public Connection(String host, int port)
throws java.net.UnknownHostException {
this(new TcpLink(host, port), false);
}
/**
* Initialise a new SMPP connection object. This is a convenience
* constructor that will create a new {@link ie.omk.smpp.net.TcpLink}object
* using the host name and port provided.
*
* @param host
* the hostname of the SMSC.
* @param port
* the port to connect to. If 0, use the default SMPP port
* number.
* @param async
* true for asyncronous communication, false for synchronous.
*/
public Connection(String host, int port, boolean async)
throws java.net.UnknownHostException {
this(new TcpLink(host, port), async);
}
/**
* Initialise a new SMPP connection object. The connection will use
* synchronous communications.
*
* @param link
* The network link object to the Smsc (cannot be null)
*/
public Connection(SmscLink link) {
this(link, false);
}
/**
* Initialise a new SMPP connection object, specifying the type of
* communication desired. See the {@link Connection}class description for
* some required knowledge on using the Connection in syncrhonous mode.
*
* @param link
没有合适的资源?快使用搜索试试~ 我知道了~
smpp.rar_SMPP jar_SMPP java_smpp_smpp send ja_smpp3.4 java
共323个文件
html:154个
java:127个
jar:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 19 浏览量
2022-09-23
06:57:47
上传
评论
收藏 6.61MB RAR 举报
温馨提示
用java实现的smpp协议,自己也没研究过.当时只是好奇才收藏了的
资源详情
资源评论
资源推荐
收起资源包目录
smpp.rar_SMPP jar_SMPP java_smpp_smpp send ja_smpp3.4 java (323个子文件)
BUILDINFO 194B
stress_recv.c 13KB
ChangeLog 92KB
.checkstyle 387B
.classpath 667B
Contributors 98B
stylesheet.css 1KB
inherit.gif 57B
stress_recv.h 2KB
index-all.html 347KB
SMPPPacket.html 135KB
Connection.html 80KB
constant-values.html 73KB
Tag.html 56KB
APIConfig.html 42KB
Bind.html 42KB
PacketStatus.html 39KB
SMPPEventAdapter.html 39KB
SMPPVersion34.html 38KB
SMPPVersion33.html 38KB
SMPPVersion.html 38KB
QueryMsgDetailsResp.html 37KB
SubmitMulti.html 36KB
SubmitMultiResp.html 35KB
QueryLastMsgsResp.html 35KB
DeliverSM.html 34KB
ParamRetrieveResp.html 34KB
QueryLastMsgs.html 34KB
ParamRetrieve.html 34KB
QueryMsgDetails.html 34KB
BindResp.html 34KB
AlertNotification.html 33KB
DeliverSMResp.html 32KB
SubmitSMResp.html 32KB
DataSMResp.html 32KB
ReplaceSM.html 32KB
CancelSM.html 32KB
QuerySMResp.html 32KB
QuerySM.html 32KB
SubmitSM.html 32KB
DataSM.html 32KB
EnquireLinkResp.html 31KB
Outbind.html 31KB
ReplaceSMResp.html 31KB
CancelSMResp.html 31KB
EnquireLink.html 31KB
UnbindResp.html 31KB
Unbind.html 31KB
SMPPRequest.html 31KB
GenericNack.html 30KB
SMPPResponse.html 30KB
BindTransmitter.html 29KB
BindTransceiver.html 29KB
BindReceiver.html 29KB
GSMConstants.html 29KB
BindTransceiverResp.html 29KB
BindTransmitterResp.html 29KB
BindReceiverResp.html 29KB
serialized-form.html 27KB
SmscLink.html 26KB
SMPPAPIExample.html 26KB
TcpLink.html 26KB
SMPPIO.html 25KB
ObjectLink.html 25KB
SimpleEventDispatcher.html 24KB
overview-tree.html 24KB
SMPPDate.html 24KB
InvalidParameterValueException.html 22KB
ReceiverExitEvent.html 22KB
AsyncTransmitter.html 22KB
TLVTable.html 22KB
ThreadedEventDispatcher.html 22KB
DefaultAlphabetEncoding.html 21KB
AsyncReceiver.html 21KB
deprecated-list.html 19KB
Address.html 18KB
EncodingFactory.html 17KB
ErrorAddress.html 17KB
AsyncReceiver2.html 16KB
SyncTransceiver.html 16KB
DefaultSequenceScheme.html 16KB
package-summary.html 16KB
SyncTransmitter.html 16KB
StreamLink.html 16KB
NumberEncoder.html 16KB
NullEncoder.html 16KB
BitmaskEncoder.html 15KB
UserGuide.html 15KB
OctetEncoder.html 15KB
StringEncoder.html 15KB
EventDispatcher.html 15KB
ReceiverExceptionEvent.html 15KB
allclasses-frame.html 15KB
Encoder.html 14KB
SMPPEvent.html 14KB
HPRoman8Encoding.html 14KB
AlphabetEncoding.html 14KB
InvalidConfigurationException.html 14KB
BadCommandIDException.html 13KB
DestinationTable.html 13KB
共 323 条
- 1
- 2
- 3
- 4
JonSco
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0