亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? session.java

?? Short Message Peer to Peer
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp;

import java.io.IOException;
import java.util.Hashtable;

import org.smpp.util.*;
import org.smpp.pdu.*;

/**
 * Class <code>Session</code> provides all methods necessary for communication
 * with SMSC using SMPP protocol, i.e. methods for sending PDUs as defined
 * in SMPP specification as well as receiving responses for sent PDUs
 * and waiting for PDUs whose sending was initiated by SMSC.<br>
 * Instance of <code>Session</code> represents one connection of ESME
 * to a SMSC. Multiple connections can be established using
 * multiple <code>Sessions</code>.
 * <p>
 * <code>Session</code> uses <code>Connection</code> object which is
 * instantiated outside of the <code>Session</code>. This way is
 * the <code>Session</code> made independent on the communication protocol
 * and <code>Session</code>'s code isn't populated by protocol dependent
 * initialisation.
 * <p>
 * Code example of binding, sending one message and unbinding:
 * <br><blockquote><pre>
 *   Connection conn = new TCPIPConnection("123.123.123.123", 6543);
 *   Session session = new Session(conn);
 *   BindRequest breq = new BindTransmitter();
 *   breq.setSystemId("MYNAME");
 *   breq.setPassword("my_pswdx");
 *   Response resp = session.bind(breq);
 *   if (resp.getCommandStatus() == Data.ESME_ROK) {
 *      SubmitSM msg = new SubmitSM();
 *      msg.setSourceAddr("3538998765432");
 *      msg.setDestAddr("3538619283746");
 *      msg.setShortMessage("Hello, world!");
 *      resp = session.submit(msg);
 *      if (resp.getCommandStatus() == Data.ESME_ROK) {
 *         System.out.println("Message submitted. Status=" + resp.getCommandStatus());
 *      } else {
 *         System.out.println("Message submission failed. Status=" + resp.getCommandStatus());
 *      }
 *      session.unbind();
 *   } else {
 *      System.out.println("Couldn't bind. Status=" + resp.getCommandStatus());
 *   }
 * </pre></blockquote>
 * Note that the cycle bind - send PDU's - unbind can be called
 * several times for once created session.
 * <p>
 * Particular methods for sending PDUs to SMSC return responses to the sent
 * PDUs. They return null if no response is received in time specified
 * by the receive timeout in receiver. This means that the methods wait
 * for response corresponding to the request.
 * The corresponding response is recognized using sequence number of the sent
 * PDU and a corresponding response command id.<br>
 * The session can work in assynchronous manner, i.e. it doesn't wait
 * for response for the sent request, instead all responses are handled
 * by instance of callback class <code>ServerPDUEventListener</code>
 * whenever they are received.<br>
 * The <code>Session</code> class checks if operations invoked are valid in
 * the current state of the session. If not, then such operation throws
 * <code>WrongSessionStateException</code> expcetion. For example it's incorrect
 * to try to submit a message if the session is bound as receiver. The checking
 * if the operation is valid in the current state of session is turned off
 * by default.
 * 
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.4 $
 * @see Connection
 * @see Transmitter
 * @see Receiver
 * @see ServerPDUEventListener
 */
public class Session extends SmppObject {
	/**
	 * Status of the connection. It's set by <code>open</code> method,
	 * which is called from <code>bind</code> method.
	 * @see #open()
	 * @see #bind(BindRequest)
	 */
	private boolean opened = false;

	/**
	 * Status of bounding. It's set by <code>bind</code> methdod if
	 * the binding is successfull.
	 * @see #bind(BindRequest)
	 */
	private boolean bound = false;

	/** Special state for actions which are never allowed for the session. */
	public static final int STATE_NOT_ALLOWED = 0x00; // 00000b

	/** The connection is closed (or not opened yet) and session isn't bound. */
	public static final int STATE_CLOSED = 0x01; // 00001b

	/** The connection is opened, but the session isn't bound. */
	public static final int STATE_OPENED = 0x02; // 00010b

	/** The session is bound as transmitter. */
	public static final int STATE_TRANSMITTER = 0x04; // 00100b

	/** The session is bound as receiver. */
	public static final int STATE_RECEIVER = 0x08; // 01000b

	/** The session is bound as transceiver. */
	public static final int STATE_TRANSCEIVER = 0x10; // 10000b

	/** Special state for actions which are always allowed (e.g. generic_nack.) */
		public static final int STATE_ALWAYS = // 11111b
	STATE_OPENED | STATE_TRANSMITTER | STATE_RECEIVER | STATE_TRANSCEIVER;

	/**
	 * Table with command id's and session states in which they can be used.
	 * For session on ESME side.
	 * @see #initialiseStateMatrix()
	 */
	private static Hashtable esmeStateMatrix;

	/**
	 * Table with command id's and session states in which they can be used.
	 * For session on MC side. Note that even if this is from the MC side
	 * the bind states are still entered from the EMSE point of veiw.
	 * E.g. for deliver_sm this table contains states receiver and transceiver,
	 * which means that MC can send PDU with deliver_sm command id only in case
	 * the ESME is bound as receiver or transceiver.<br>
	 * <emp>Note:</emp> The MC state matrix is not completly supported by
	 * the current implementation of session, so it's currently altered
	 * to reflect the impplementation.
	 * @see #initialiseStateMatrix()
	 */
	private static Hashtable mcStateMatrix;

	/**
	 * If PDU with unknown command id is probed this says if this PDU is
	 * allowed or not. Generaly it's not good idea to allow unknown PDUs, but
	 * for backward compatiblity we leave it set to false.
	 */
	private boolean disallowUnknownPDU = false;

	/**
	 * The current state of this Session.
	 * @see #esmeStateMatrix
	 * @see #mcStateMatrix
	 * @see #setState(int)
	 * @see #getState()
	 */
	private int state = STATE_CLOSED;

	/**
	 * If the checking of states is active. It's generaly good idea to leave it
	 * set to true, it'll save you communication bandwidth (MC should reject your
	 * PDU if you are in wrong state) and it'll discover bad logic in your application.
	 * For backward compatibility we set that the state is NOT checked.
	 * @see #enableStateChecking()
	 * @see #disableStateChecking()
	 */
	private boolean stateChecking = false;

	/**
	 * Indicates that the session is session for ESME 'point of view.'
	 * @see #type
	 */
	public static final int TYPE_ESME = 1;

	/**
	 * Indicates that the session is session for MC 'point of view.'
	 * MC is Message Center and it is a term for generic Message Centre such as SMSC.
	 * @see #type
	 */
	public static final int TYPE_MC = 2;

	/**
	 * If this session is ESME session or if it is used in MC (or simulator
	 * or routing entity, simply the other side of normal ESME).
	 * Normally this would be equal to TYPE_ESME as mostly this library will be used
	 * for developing ESME applications and not MCs. If you don't understand
	 * what is this variable for, just leave it as it is.
	 * @see #setType(int)
	 * @see #getType()
	 */
	private int type = TYPE_ESME;

	/**
	 * The connection object. It's created outside of the <code>Session</code>
	 * class and passed as a parameter during the <code>Session</code>
	 * creation. It's then passed to <code>Transmitter</code> and
	 * <code>Receiver</code>.
	 * @see Connection
	 * @see TCPIPConnection
	 * @see Transmitter
	 * @see Receiver
	 */
	private Connection connection;

	/**
	 * Object used for transmitting of PDUs over connection.
	 * @see Transmitter
	 */
	private Transmitter transmitter;

	/**
	 * Object used for receiving of PDU from connection.
	 * @see Receiver
	 */
	private Receiver receiver;

	/**
	 * If the receiving is asynchronous, <code>pduListener</code> must
	 * contain the callback object used for processing of PDUs received
	 * from the SMSC. <code>Receiver</code> after receiving a PDU passes
	 * the received PDU to apropriate member function of the processor.
	 * @see #asynchronous
	 * @see #setServerPDUEventListener(ServerPDUEventListener)
	 * @see #bind(BindRequest)
	 * @see Receiver
	 */
	private ServerPDUEventListener pduListener = null;

	/**
	 * Indicates that the sending of PDUs to the SMSC is asynchronous, i.e.
	 * the session doesn't wait for a response to the sent request as well as
	 * the <code>receive</code> functions will return null as all received
	 * PDUs are passed to the <code>pduListener</code> object in
	 * the <code>receiver</code>.
	 * @see #pduListener
	 * @see #setServerPDUEventListener(ServerPDUEventListener)
	 * @see #bind(BindRequest)
	 * @see Receiver
	 */
	private boolean asynchronous = false;

	/**
	 * Default constructor made protected as it's not desirable to
	 * allow creation of <code>Session</code> without providing 
	 * <code>Connection</code>.
	 */
	protected Session() {
	}

	/**
	 * Creates <code>Session</code> which uses provided <code>Connection</code>.
	 * In most cases the <code>connection</code> parameter will be an instance
	 * of <code>TCPIPConnection</code> class.
	 *
	 * @param   connection   connection used for transmitting and receiving
	 *                       the data
	 */
	public Session(Connection connection) {
		this.connection = connection;
	}

	/**
	 * Opens the connection for communication.
	 * Sets indication that the connection is opened.
	 *
	 * @exception IOException exception during communication
	 */
	public void open() throws IOException, WrongSessionStateException {
		checkState(STATE_CLOSED);
		if (!opened) {
			connection.open();
			opened = true;
			setState(STATE_OPENED);
		}
	}

	/**
	 * Closes the connection for communication.
	 * Sets indication that the connection is not opened.
	 *
	 * @exception IOException exception during communication
	 */
	public void close() throws IOException, WrongSessionStateException {
		checkState(STATE_OPENED);
		if (connection.isOpened()) {
			connection.close();
			opened = false;
			setState(STATE_CLOSED);
		}
	}

	/**
	 * Returns of the connection is opened.
	 * @return current status of connection
	 */
	public boolean isOpened() {
		return opened && connection.isOpened();
	}

	/**
	 * Returns if the session is bound to SMSC.
	 * @return current status of bound
	 */
	public boolean isBound() {
		return bound;
	}

	/**
	 * Sets the listener which is passed all PDUs received by the
	 * <code>Receiver</code> from the SMSC.
	 * Note that this method implicitly sets asynchronous type of
	 * receiving.
	 * @param pduListener the listener which processes the received PDUs
	 */
	private void setServerPDUEventListener(ServerPDUEventListener pduListener) {
		this.pduListener = pduListener;
		receiver.setServerPDUEventListener(pduListener);
		asynchronous = pduListener != null;
	}

	/**
	 * Returns the current <code>ServerPDUEventListener</code> set for
	 * this session.
	 */
	private ServerPDUEventListener getServerPDUEventListener() {
		return pduListener;
	}

	/**
	 * Sets the type of the session. The type can be either ESME or MC viewed
	 * from the side where the instance of the <code>Session</code> is used.
	 * Set the type of the session before opening the session.
	 * @param type the new type of the session
	 * @see #getType()
	 * @see #TYPE_ESME
	 * @see #TYPE_MC
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * Returns the type of the session.
	 * @return the current type of the session.
	 * @see #setType(int)
	 * @see #TYPE_ESME

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡欧美aaaaa| av在线不卡免费看| 日韩西西人体444www| 天堂资源在线中文精品| 在线免费观看一区| 亚洲免费观看高清完整版在线观看 | 日韩精品最新网址| 日韩精品一级二级 | 精品少妇一区二区三区免费观看 | 国产成人三级在线观看| 久久看人人爽人人| 国产成人av电影在线观看| 久久毛片高清国产| 国产很黄免费观看久久| 久久午夜色播影院免费高清| 国内精品国产成人| 久久免费的精品国产v∧| 狠狠色狠狠色综合日日91app| 欧美一二三区精品| 久久国产视频网| 精品噜噜噜噜久久久久久久久试看| 另类人妖一区二区av| xf在线a精品一区二区视频网站| 精品一区二区三区在线播放视频| 欧美tickling网站挠脚心| 国产揄拍国内精品对白| 久久九九影视网| 成人午夜免费电影| 1区2区3区国产精品| 91麻豆国产福利精品| 亚洲午夜一区二区三区| 欧美日韩不卡视频| 美国十次综合导航| 久久久久99精品一区| jizzjizzjizz欧美| 亚洲黄色尤物视频| 制服丝袜av成人在线看| 麻豆成人免费电影| 国产性色一区二区| av亚洲精华国产精华精| 亚洲一区在线免费观看| 欧美丰满高潮xxxx喷水动漫| 久久av中文字幕片| 欧美激情艳妇裸体舞| 色噜噜狠狠成人中文综合 | 亚洲专区一二三| 91精品国产综合久久福利| 国产真实乱子伦精品视频| 国产精品久久久久久久第一福利| 日本福利一区二区| 奇米精品一区二区三区在线观看 | 国产精品自拍在线| 亚洲欧美怡红院| 欧美日韩中文另类| 精品一区二区影视| 亚洲人一二三区| 欧美精品18+| 国产成人在线观看免费网站| 亚洲乱码日产精品bd| 日韩免费看的电影| 91在线视频观看| 日韩中文欧美在线| 中文字幕av不卡| 欧美日韩视频第一区| 国产麻豆午夜三级精品| 亚洲男人天堂av网| 日韩三级视频在线看| 高清beeg欧美| 五月天婷婷综合| 国产女同互慰高潮91漫画| 欧美日韩一区二区三区免费看 | 国产揄拍国内精品对白| 亚洲精品国产第一综合99久久| 欧美一区二区精品在线| 99精品久久只有精品| 美女视频黄 久久| 亚洲色图一区二区三区| 精品成人一区二区三区四区| 色综合天天天天做夜夜夜夜做| 裸体歌舞表演一区二区| 亚洲激情在线激情| 久久精品亚洲一区二区三区浴池| 在线观看日韩一区| 国产精品亚洲第一区在线暖暖韩国| 亚洲一区二区中文在线| 欧美激情一区二区| 日韩一级精品视频在线观看| 色综合天天综合网天天狠天天 | 精品伊人久久久久7777人| 一区二区三区四区在线播放 | 亚洲午夜久久久久久久久电影网| 久久日韩精品一区二区五区| 欧美色综合影院| 国产精品 日产精品 欧美精品| 午夜日韩在线观看| 国产精品久久久久久久岛一牛影视| 欧美一区二区三区视频免费| av一二三不卡影片| 国产乱人伦偷精品视频免下载 | 亚洲欧洲成人av每日更新| 欧美精品一区视频| 6080亚洲精品一区二区| 在线观看区一区二| 成人妖精视频yjsp地址| 韩国毛片一区二区三区| 日韩电影在线观看网站| 亚洲国产精品自拍| 亚洲精品中文在线| 中文字幕中文字幕中文字幕亚洲无线| 精品日本一线二线三线不卡| 欧美高清视频一二三区 | 国产欧美日本一区二区三区| 精品国产伦一区二区三区观看体验| 欧美日韩国产天堂| 在线免费观看视频一区| 色综合天天综合狠狠| 成人av电影免费在线播放| 精品一区二区三区蜜桃| 麻豆一区二区三区| 美国av一区二区| 蜜臀精品一区二区三区在线观看| 丝袜美腿一区二区三区| 午夜欧美2019年伦理| 亚洲成人自拍偷拍| 亚洲伊人伊色伊影伊综合网| 尤物在线观看一区| 一区二区三区国产| 亚洲精品国产a久久久久久| 最新欧美精品一区二区三区| 国产精品乱人伦| 中文字幕乱码一区二区免费| 国产日韩v精品一区二区| 国产丝袜美腿一区二区三区| 欧美—级在线免费片| 国产欧美一区二区精品性色超碰 | 精品欧美乱码久久久久久1区2区| 日韩欧美国产一二三区| 欧美理论片在线| 欧美一区二区日韩| 欧美电影免费提供在线观看| 精品国精品自拍自在线| 久久伊人蜜桃av一区二区| 精品成人佐山爱一区二区| 久久色.com| 国产女人18毛片水真多成人如厕| 亚洲国产精品av| 国产精品久久久久久久午夜片| 中文字幕国产精品一区二区| 国产精品久久久久久久久久免费看| 国产精品久久久久久久久图文区| 成人免费小视频| 一区二区三区高清在线| 午夜精品久久久久久久蜜桃app| 天天免费综合色| 九九国产精品视频| 国产91在线观看| 一本色道久久加勒比精品| 欧美在线视频你懂得| 在线播放中文一区| 精品久久久久久久一区二区蜜臀| 国产视频一区二区在线观看| 综合久久给合久久狠狠狠97色| 亚洲伊人伊色伊影伊综合网| 免费成人在线播放| 国产盗摄一区二区三区| 91亚洲资源网| 欧美精品在欧美一区二区少妇| 精品日韩在线一区| 国产精品久久久久久久久晋中| 亚洲一区二区精品视频| 日韩av一区二区在线影视| 国产福利不卡视频| 91久久精品一区二区三区| 欧美一区二区三区精品| 国产欧美一区二区三区沐欲 | 国产三级精品三级| 亚洲女性喷水在线观看一区| 日本视频一区二区三区| 国产麻豆视频精品| 91久久精品午夜一区二区| 日韩美一区二区三区| 中文字幕中文在线不卡住| 亚洲第一电影网| 国产精品一区在线观看乱码 | 国产成人av电影在线| 欧美羞羞免费网站| 337p粉嫩大胆色噜噜噜噜亚洲| 国产精品久久久久久久久果冻传媒| 亚洲大型综合色站| 国产99久久久国产精品| 欧美日韩一区三区四区| 国产日韩一级二级三级| 午夜av一区二区| 夫妻av一区二区| 欧美高清一级片在线| 综合在线观看色| 青青国产91久久久久久| 色综合久久久久久久久久久| 精品国产精品一区二区夜夜嗨| 亚洲精品一二三四区|