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

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

?? receiver.java

?? Short Message Peer to Peer
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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 org.smpp.pdu.GenericNack;
import org.smpp.pdu.PDU;
import org.smpp.pdu.InvalidPDUException;
import org.smpp.pdu.PDUException;
import org.smpp.pdu.UnknownCommandIdException;
import org.smpp.util.Queue;
import org.smpp.util.Unprocessed;

/**
 * <code>Receiver</code> is class used for receiving PDUs from SMSC.
 * It can be used two ways: it has methods for synchronous (blocking)
 * receiving of PDUs and as it is derived from <code>ReceiverBase</code>
 * whic on turn is derived from <code>ProcessingThread</code> class,
 * it can also receive PDUs on background and puts them into a queue.
 * 
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.2 $
 * @see ReceiverBase
 * @see Connection
 * @see Session
 * @see Queue
 */

public class Receiver extends ReceiverBase {
	/**
	 * Name of the thread created when starting
	 * the <code>ProcessingThread</code>.
	 * @see org.smpp.util.ProcessingThread#start()
	 * @see org.smpp.util.ProcessingThread#generateIndexedThreadName()
	 */
	private static final String RECEIVER_THREAD_NAME = "Receiver";

	/**
	 * The correspondent transmitter for transmitting PDUs.
	 * It's used for sending of generic negative acknowledges, if necessary.
	 * It is passed to the receiver as a parameter during construction.
	 * 
	 * @see #receiveAsync()
	 */
	private Transmitter transmitter = null;

	/**
	 * The network connection which is used for receiving data.
	 * It is passed to the receiver as a parameter during construction.
	 */
	private Connection connection = null;

	/**
	 * The queue which holds the received PDUs.
	 * As the PDUs are received in asynchronnous manner, they are stored
	 * to a queue from which they can be get using method
	 * <code>receive</code>. PDUs are stored to the queue if and only if the
	 * <code>Receiver</code> is started as a separate thread using method
	 * <code>start</code>.
	 *
	 * @see #receive(long)
	 * @see #receive(PDU)
	 * @see #start()
	 * @see ReceiverBase#start()
	 */
	private Queue pduQueue = new Queue();

	/**
	 * This timeout specifies for how long will go the receiving into wait
	 * if the PDU (expected or any) isn't in the <code>pduQueue</code> yet.
	 * After that the queue is probed again (etc.) until receiving timeout 
	 * expires or the PDU is received.
	 *
	 * @see #tryReceivePDU(Connection,PDU)
	 */
	private long queueWaitTimeout = Data.QUEUE_TIMEOUT;

	/**
	 * Indication if the <code>Receiver</code> is receiving on background as an
	 * extra thread.
	 *
	 * @see #start()
	 * @see #tryReceivePDU(Connection,PDU)
	 */
	private boolean receiver = false;

	/**
	 * This object holds data received from connection which aren't complete
	 * PDU yet. If this situation occurs, it's likely that the data
	 * will be received the next time when another attempt
	 * to receive data from the connection occurs. Its used in
	 * <code>ReceiverBase</code>'s <code>receivePDUFromConnection</code>
	 * method.
	 *
	 * @see ReceiverBase#receivePDUFromConnection(Connection,Unprocessed)
	 */
	private Unprocessed unprocessed = new Unprocessed();

	/**
	 * 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)
	 */
	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)
	 */
	private boolean asynchronous = false;

	/**
	 * This constructor sets the connection to receive the messages from.
	 *
	 * @param connection the connection to use for receiving
	 * @see Connection
	 */
	public Receiver(Connection connection) {
		this.connection = connection;
	}

	/**
	 * This constructor sets the connection to receive the messages from
	 * and a transmitter for sending generic negative acknowledges
	 * if necessary.
	 *
	 * @param transmitter the transmitter to use for sending
	 *                    <code>GenericNack</code>
	 * @param connection  the connection to use for receiving and transmitting
	 * @see Transmitter
	 * @see Connection
	 * @see GenericNack
	 */
	public Receiver(Transmitter transmitter, Connection connection) {
		this.transmitter = transmitter;
		this.connection = connection;
	}

	/**
	 * Returns if the receiver receives PDUs on background as an extra thread.
	 *
	 * @see #receiver
	 */
	public boolean isReceiver() {
		return receiver;
	}

	/**
	 * Sets the event listener for asynchronous <code>Receiver</code>.
	 * In case there are unprocessed PDUs in the queue,
	 * they are removed from the queue and passed to the newly set listener.
	 */
	public synchronized void setServerPDUEventListener(ServerPDUEventListener pduListener) {
		this.pduListener = pduListener;
		this.asynchronous = pduListener != null;
		if (asynchronous) {
			// let's remove all pdu's from the queue as since now all
			// processing should be asynchronous -- it's not wise to
			// expect that the programmer will try AFTER setting the listener
			// to call receive() which when in sync mode removes the pdus from
			// the queue
			PDU pdu;
			int queueSize;
			synchronized (pduQueue) {
				queueSize = pduQueue.size();
				for (int i = 0; i < queueSize; i++) {
					pdu = (PDU) pduQueue.dequeue();
					process(pdu);
				}
			}
		}
	}

	/**
	 * Resets unprocessed data and starts receiving on the background.
	 *
	 * @see ReceiverBase#start()
	 */
	public void start() {
		debug.write(DRXTX, "Receiver starting");
		receiver = true;
		unprocessed.reset();
		super.start();
		debug.write(DRXTX, "Receiver started");
	}

	/**
	 * Stops receiving on the background.
	 *
	 * @see ReceiverBase#stop()
	 */
	public void stop() {
		debug.write(DRXTX, "Receiver stoping");
		if (isReceiver()) {
			super.stop();
			receiver = false;
		}
		debug.write(DRXTX, "Receiver stoped");
	}

	/**
	 * This method receives a PDU or returns PDU received on background,
	 * if there is any. It tries to receive a PDU for the specified timeout.
	 * If the receiver is asynchronous, then no attempt to receive a PDU
	 * and <code>null</code> is returned.
	 * The function calls are nested as follows:<br>
	 * <ul>
	 *   <li>No background receiver thread<br><code>
	 *       Receiver.receive(long)<br>
	 *       ReceiverBase.tryReceivePDUWithTimeout(Connection,PDU,long)<br>
	 *       Receiver.tryReceivePDU(Connection,PDU)<br>
	 *       ReceiverBase.receivePDUFromConnection<br>
	 *       Connection.receive()</code>
	 *   <li>Has background receiver thread<br><code>
	 *       Receiver.receive(long)<br>
	 *       ReceiverBase.tryReceivePDUWithTimeout(Connection,PDU,long)<br>
	 *       Receiver.tryReceivePDU(Connection,PDU)<br>
	 *       Queue.dequeue(PDU)</code><br>
	 *       and the ReceiverBase.run() function which actually receives the
	 *       PDUs and stores them to a queue looks as follows:<br><code>
	 *       ReceiverBase.run()<br>
	 *       Receiver.receiveAsync()<br>
	 *       ReceiverBase.receivePDUFromConnection<br>
	 *       Connection.receive()</code>
	 *
	 * @param timeout for how long is tried to receive a PDU
	 * @return the received PDU or null if none received for the spec. timeout
	 * 
	 * @exception IOException exception during communication
	 * @exception PDUException incorrect format of PDU
	 * @exception TimeoutException rest of PDU not received for too long time
	 * @exception UnknownCommandIdException PDU with unknown id was received
	 * @see ReceiverBase#tryReceivePDUWithTimeout(Connection,PDU,long)
	 */
	public synchronized PDU receive(long timeout)
		throws UnknownCommandIdException, TimeoutException, NotSynchronousException, PDUException, IOException {
		PDU pdu = null;
		if (!asynchronous) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
高清不卡一区二区| 另类成人小视频在线| 色哟哟国产精品免费观看| 最新国产精品久久精品| 色婷婷久久久久swag精品| 亚洲一区免费观看| 日韩丝袜美女视频| 国产伦精品一区二区三区视频青涩| 国产欧美精品一区| 成人午夜视频在线观看| 亚洲精品乱码久久久久久日本蜜臀| 亚洲电影一区二区三区| 91精品国产一区二区人妖| 日韩在线观看一区二区| 日韩免费看网站| 成人免费av资源| 亚洲成人av免费| 久久青草欧美一区二区三区| 色哟哟一区二区在线观看| 日本欧美久久久久免费播放网| 99久久精品免费观看| 午夜精品福利一区二区三区蜜桃| 99国产精品久| 免费在线欧美视频| 中文字幕在线观看一区| 91精品婷婷国产综合久久竹菊| 亚洲男人天堂一区| 日韩欧美中文字幕一区| 99久久婷婷国产| 毛片基地黄久久久久久天堂| 中文字幕在线不卡国产视频| 67194成人在线观看| 成人午夜视频免费看| 丝袜a∨在线一区二区三区不卡| 99re这里都是精品| 麻豆成人91精品二区三区| 中文字幕一区二区在线播放 | 色域天天综合网| 免费不卡在线观看| 亚洲激情六月丁香| 26uuu另类欧美| 欧美日韩在线免费视频| 粉嫩绯色av一区二区在线观看| 精品国产不卡一区二区三区| 91黄视频在线| 成人91在线观看| 国产中文一区二区三区| 三级亚洲高清视频| 一区二区三区中文在线| 亚洲国产精品精华液2区45| 欧美美女喷水视频| 色综合中文字幕国产 | 悠悠色在线精品| 日韩免费福利电影在线观看| 色哟哟一区二区| 成人的网站免费观看| 国产精品资源网| 六月丁香婷婷色狠狠久久| 亚洲高清不卡在线观看| 亚洲精品成人少妇| √…a在线天堂一区| 国产清纯美女被跳蛋高潮一区二区久久w| 国内精品国产成人| 午夜成人免费电影| 亚洲综合999| 亚洲一区二区三区自拍| 亚洲天堂网中文字| 亚洲婷婷在线视频| 中文av一区二区| 国产精品午夜在线| 国产精品视频一二三区| 欧美激情一区二区三区在线| 精品国产欧美一区二区| 精品国精品国产| 久久综合成人精品亚洲另类欧美 | 成人高清伦理免费影院在线观看| 中文字幕永久在线不卡| 国产精品美女久久福利网站| 26uuu精品一区二区| 久久免费的精品国产v∧| 久久这里只有精品6| 欧美激情中文不卡| 国产精品久久久久aaaa| 中文字幕亚洲综合久久菠萝蜜| 欧美肥胖老妇做爰| 日韩亚洲欧美一区二区三区| 日韩视频免费观看高清完整版在线观看| 久久se这里有精品| 国产精品乡下勾搭老头1| 国产一区二区剧情av在线| 国产河南妇女毛片精品久久久| 亚洲三级在线观看| 亚洲h在线观看| 另类欧美日韩国产在线| 国产真实乱偷精品视频免| 国产69精品久久777的优势| 粉嫩av一区二区三区在线播放 | 日韩理论片中文av| 亚洲国产日韩综合久久精品| 欧美aaaaa成人免费观看视频| 最新久久zyz资源站| 亚洲一级电影视频| 国内一区二区在线| 91在线观看下载| 91精品国产综合久久久蜜臀图片| 91啪亚洲精品| 欧美日韩精品专区| 久久精品欧美一区二区三区不卡| 日韩午夜在线观看视频| 国产午夜精品一区二区三区四区 | 日韩精品五月天| 久久99热这里只有精品| 国产成a人亚洲精品| 欧美综合在线视频| 欧美日韩成人综合在线一区二区| 色一区在线观看| 日韩一二三区视频| 亚洲人xxxx| 麻豆视频一区二区| 91免费版pro下载短视频| 91精品国产色综合久久不卡蜜臀 | 国产·精品毛片| 欧美日韩精品专区| 国产免费观看久久| 日韩成人av影视| 成人av影视在线观看| 欧美日韩午夜影院| 国产精品网站导航| 老汉av免费一区二区三区 | 日韩欧美在线网站| 伊人性伊人情综合网| 精品一区二区在线免费观看| 色综合久久综合中文综合网| 久久老女人爱爱| 亚洲va欧美va人人爽午夜| www.亚洲人| 久久夜色精品一区| 亚洲二区在线视频| 91亚洲男人天堂| 欧美videos中文字幕| 一区二区成人在线| 成人免费视频app| 26uuu国产日韩综合| 天天影视涩香欲综合网 | 91精品国产91热久久久做人人| 欧美日韩在线播放三区| 中文字幕日韩一区| 精品一二三四区| 欧美性色黄大片| 亚洲男同性视频| 国产亚洲欧美一级| 91九色02白丝porn| 久久精品99国产精品日本| 欧美变态tickle挠乳网站| 日韩免费看网站| 亚洲欧洲日本在线| 成人高清视频免费观看| 久久久另类综合| 久久99精品久久久久| 欧美一区二区在线视频| 午夜精品久久久久久久99樱桃| 亚洲卡通动漫在线| 99久久综合色| 日韩一区中文字幕| 粉嫩欧美一区二区三区高清影视| 另类调教123区 | 成人黄色在线看| 中文字幕+乱码+中文字幕一区| 亚洲欧洲www| 91蜜桃视频在线| 亚洲少妇30p| 在线观看免费视频综合| 亚洲一区二区美女| 欧美乱熟臀69xxxxxx| 日本成人在线视频网站| 精品国产污网站| 久久精品国内一区二区三区| 精品久久一区二区三区| 激情久久五月天| 国产欧美一区二区精品性| 国产传媒欧美日韩成人| 国产精品网站在线| 日本高清成人免费播放| 亚洲午夜免费视频| 日韩欧美黄色影院| 国产精品一区二区你懂的| 国产精品久久久久久久久果冻传媒| 石原莉奈在线亚洲三区| 91精品麻豆日日躁夜夜躁| 久久精品国产亚洲a| 亚洲国产精品国自产拍av| eeuss影院一区二区三区| 亚洲三级电影网站| 欧美群妇大交群的观看方式| 蜜桃久久av一区| 国产三级精品三级| 欧美日韩一区久久| 精品午夜一区二区三区在线观看| 在线观看区一区二| 激情综合色综合久久综合|