📄 smpptransmitter.java
字号:
/* * Java SMPP API * Copyright (C) 1998 - 2001 by Oran Kelly * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * A copy of the LGPL can be viewed at http://www.gnu.org/copyleft/lesser.html * Java SMPP API author: orank@users.sf.net * Java SMPP API Homepage: http://smppapi.sourceforge.net/ */package ie.omk.smpp;import java.io.*;import java.util.*;import ie.omk.smpp.message.*;import ie.omk.smpp.net.*;import ie.omk.smpp.util.SMPPDate;import ie.omk.debug.Debug;/** Transmitter implementation of the SMPP Connection. * @author Oran Kelly * @version 1.0 */public class SmppTransmitter extends ie.omk.smpp.SmppConnection{ /** Create a new smpp Transmitter connection * @param link The network link to the Smsc */ public SmppTransmitter(SmscLink link) { super(link); } /** Create a new Smpp transmitter specifying the type of communications * desired. * @param link The network link object to the Smsc (cannot be null) * @param async true for asyncronous communication, false for synchronous. * @exception java.lang.NullPointerException If the link is null */ public SmppTransmitter(SmscLink link, boolean async) { super(link, async); } /** Bind to the SMSC as a transmitter. This method will * send a bind_transmitter packet to the SMSC. If the network * connection to the SMSC is not already open, it will be opened in * this method. * See the description of bind in ie.omk.smpp.SmppConnection.bind. * @return The bind response, or null if asynchronous communication is * used. * @exception ie.omk.smpp.AlreadyBoundException if the connection is * already bound to the SMSC. * @exception java.io.IOException If there is a network error * @see ie.omk.smpp.SmppConnection#bind */ public SMPPResponse bind(String systemID, String password, String systemType, SmeAddress sourceRange) throws java.io.IOException, ie.omk.smpp.SMPPException { // Make sure we're not already bound if(getState() != UNBOUND) throw new AlreadyBoundException(); // Open the network connection if necessary. super.openLink(); BindTransmitter t = new BindTransmitter(); t.setSystemId(systemID); t.setPassword(password); t.setSystemType(systemType); t.setInterfaceVersion(super.interfaceVersion); if (sourceRange != null) { t.setAddressTon(sourceRange.getTON()); t.setAddressNpi(sourceRange.getNPI()); t.setAddressRange(sourceRange.getAddress()); } Debug.d(this ,"bind", "bind_transmitter sent", 3); return ((SMPPResponse)sendRequest(t)); } /** Submit a message to an ESME * @param msg The text of the message. Must be less than 161 characters * (may be null) * @param flags Message flags information * @param dst Destination ESME to send the message to (may be null) * @return The submit message response, or null if asynchronous * communication is used. * @exception java.io.IOException If a network error occurs * @see SmeAddress * @see SmppTransmitter#submitMulti * @deprecated This method will disappear from this class within the next 2 * releases. */ public SubmitSMResp submitMessage(String msg, MsgFlags flags, SmeAddress dst) throws java.io.IOException, ie.omk.smpp.SMPPException { return (this.submitMessage(msg, flags, null, dst, null, null)); } /** Submit a message to an ESME * @param msg The text of the message. Must be less than 161 characters * (may be null) * @param flags Message flags information * @param src Source ESME this message is from (may be null) * @param dst Destination ESME to send the message to (may be null) * @return The submit message response, or null if asynchronous * communication is used. * @exception java.io.IOException If a network error occurs * @see SmeAddress * @see SmppTransmitter#submitMulti * @deprecated This method will disappear from this class within the next 2 * releases. */ public SubmitSMResp submitMessage(String msg, MsgFlags flags, SmeAddress src, SmeAddress dst) throws java.io.IOException, ie.omk.smpp.SMPPException { return (this.submitMessage(msg, flags, src, dst, null, null)); } /** Submit a message to an ESME * @param msg The text of the message. Must be less than 161 characters * @param flags Message flags information * @param src Source ESME this message is from (may be null) * @param dst Destination ESME to send the message to (may be null) * @param del Absolute delivery time of the message (may be null) * @param valid The time of expiry of this message (may be null) * @return The submit message response, or null if asynchronous * communication is used. * @exception java.io.IOException If a network error occurs * @see SmeAddress * @see SmppTransmitter#submitMulti * @deprecated This method will disappear from this class within the next 2 * releases. */ public SubmitSMResp submitMessage(String msg, MsgFlags flags, SmeAddress src, SmeAddress dst, SMPPDate del, SMPPDate valid) throws java.io.IOException, ie.omk.smpp.SMPPException { SubmitSM s = new SubmitSM(); s.setPriority(flags.priority); s.setRegistered(flags.registered); s.setEsmClass(flags.esm_class); s.setProtocolID(flags.protocol); s.setDataCoding(flags.data_coding); s.setDefaultMsg(flags.default_msg); s.setMessageText(msg); s.setDestination(dst); if(src != null) s.setSource(src); SMPPResponse resp = sendRequest(s); Debug.d(this, "submitMessage", "submit_sm send", 3); return ((SubmitSMResp)resp); } /** Submit a message to multiple destinations * @param msg The text of the message. Must be less than 161 characters * (may be null) * @param flags Message flags information * @param src Source ESME this message is from (may be null) * @param dst Table of SmeAddress structures to send the message to * @param del The absolute delivery time of the message (may be null) * @param valid The validity period of the message, after which it will * @return The submit multi response, or null if asynchronous * communication is used. * @exception java.io.IOException If a network error occurs * @see SmeAddress * @deprecated This method will disappear from this class within the next 2 * releases. */ public SubmitMultiResp submitMulti(String msg, MsgFlags flags, SmeAddress src, SmeAddress dst[]) throws java.io.IOException, ie.omk.smpp.SMPPException { return (this.submitMulti(msg, flags, src, dst, null, null)); } /** Submit a message to multiple destinations * @param msg The text of the message. Must be less than 161 characters * (may be null) * @param flags Message flags information * @param src Source ESME this message is from (may be null) * @param dst Table of SmeAddress structures to send the message to * @param del The absolute delivery time of the message (may be null) * @param valid The validity period of the message, after which it will * @return The submit multi response, or null if asynchronous * communication is used. * @exception ie.omk.smpp.InvalidDestinationCountException if the * destination table contains 0 addresses. There is currently no upper * limit. * @exception ie.omk.smpp.InvalidReplaceIfPresentException if the * replace-if-present flag is set and there are more than 1 destination. * @exception java.io.IOException If a network error occurs * @see SmeAddress * @see SmppTransmitter#submitMulti * @deprecated This method will disappear from this class within the next 2 * releases. */ public SubmitMultiResp submitMulti(String msg, MsgFlags flags, SmeAddress src, SmeAddress dst[], SMPPDate del, SMPPDate valid) throws java.io.IOException, ie.omk.smpp.SMPPException { int loop = 0; SubmitMulti s = new SubmitMulti(); s.setPriority(flags.priority); s.setRegistered(flags.registered); s.setEsmClass(flags.esm_class); s.setProtocolID(flags.protocol); s.setDataCoding(flags.data_coding); s.setDefaultMsg(flags.default_msg); s.setMessageText(msg); if(src != null) s.setSource(src); // Just to make sure a message doesn't get sent to 0 destinations if(dst == null || dst.length == 0) throw new InvalidDestinationCountException(); // Add in all the destinations for(loop=0; loop<dst.length; loop++) s.addDestination(dst[loop]); // Cannot use replace-if-present to more than one destination if(dst.length > 1 && flags.replace_if_present) throw new InvalidReplaceIfPresentException();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -