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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? simulator.java

?? Short Message Peer to Peer
?? JAVA
字號(hào):
/*
 * 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.smscsim;

import java.io.*;

import org.smpp.debug.*;
import org.smpp.SmppObject;
import org.smpp.pdu.DeliverSM;
import org.smpp.pdu.PDUException;
import org.smpp.pdu.WrongLengthOfStringException;
import org.smpp.smscsim.SimulatorPDUProcessor;
import org.smpp.smscsim.SimulatorPDUProcessorFactory;
import org.smpp.smscsim.util.Table;

/**
 * Class <code>Simulator</code> is an application class behaving as a real
 * SMSC with SMPP interface.
 * Clients (ESMEs) can bind to it, send requests to which this application
 * generates responses. It also allows to send message to the bound client.
 * It's primary use is for developers creating their SMPP applications to lessen
 * the use of real SMSC. Should any extra functionality is required,
 * the developers can add it to this application. Multiple clients are supported.
 * Transmitter/receiver/transciever bound modes are supported. The bounding clients
 * are authenticated using text file with user definitions.
 * <p>
 * This simulator application uses <code>SimulatorPDUProcessor</code> to process
 * the PDUs received from the clients.
 * <p>
 * To run this application using <b>smpp.jar</b> and <b>smscsim.jar</b> library files execute
 * the following command:
 * <p>
 * <code>java -cp smpp.jar:smscsim.jar org.smpp.smscsim.Simulator</code>
 * <p>
 * If your libraries are stored in other that default directory, use the
 * directory name in the <code>-cp</code> argument.
 * 
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.3 $
 * @see SimulatorPDUProcessor
 * @see SimulatorPDUProcessorFactory
 * @see SMSCListener
 * @see SMSCSession
 * @see org.smpp.smscsim.util.BasicTableParser
 */
public class Simulator {
	static final String copyright =
		"Copyright (c) 1996-2001 Logica Mobile Networks Limited\n"
			+ "This product includes software developed by Logica by whom copyright\n"
			+ "and know-how are retained, all rights reserved.\n";

	static {
		System.out.println(copyright);
	}

	/**
	 * Name of file with user (client) authentication information.
	 */
	static String usersFileName = "etc/users.txt";

	/**
	 * Directory for creating of debug and event files.
	 */
	static final String dbgDir = "./";

	/**
	 * The debug object.
	 */
	static Debug debug = new FileDebug(dbgDir, "sim.dbg");

	/**
	 * The event object.
	 */
	static Event event = new FileEvent(dbgDir, "sim.evt");

	public static final int DSIM = 16;
	public static final int DSIMD = 17;
	public static final int DSIMD2 = 18;

	static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));

	boolean keepRunning = true;
	private SMSCListener smscListener = null;
	private SimulatorPDUProcessorFactory factory = null;
	private PDUProcessorGroup processors = null;
	private ShortMessageStore messageStore = null;
	private DeliveryInfoSender deliveryInfoSender = null;
	private Table users = null;
	private boolean displayInfo = true;

	private Simulator() {
	}

	/**
	 * The main function of the application displays menu with available
	 * options.
	 */
	public static void main(String args[]) throws IOException {
		SmppObject.setDebug(debug);
		SmppObject.setEvent(event);
		debug.activate();
		event.activate();
		debug.deactivate(SmppObject.DRXTXD2);
		debug.deactivate(SmppObject.DPDUD);
		debug.deactivate(SmppObject.DCOMD);
		debug.deactivate(DSIMD2);
		Simulator menu = new Simulator();
		menu.menu();
	}

	/**
	 * Displays menu with available simulator options such as starting and
	 * stopping listener, listing all currently connected clients,
	 * sending of a message to a client, listing all received messages
	 * and reloading of user (client) definition file.
	 */
	protected void menu() throws IOException {
		debug.write("simulator started");

		keepRunning = true;
		String option = "1";
		int optionInt;

		while (keepRunning) {
			System.out.println();
			System.out.println("- 1 start simulation");
			System.out.println("- 2 stop simulation");
			System.out.println("- 3 list clients");
			System.out.println("- 4 send message");
			System.out.println("- 5 list messages");
			System.out.println("- 6 reload users file");
			System.out.println("- 7 log to screen " + (displayInfo ? "off" : "on"));
			System.out.println("- 0 exit");
			System.out.print("> ");
			optionInt = -1;
			try {
				option = keyboard.readLine();
				optionInt = Integer.parseInt(option);
			} catch (Exception e) {
				debug.write("exception reading keyboard " + e);
				optionInt = -1;
			}
			switch (optionInt) {
				case 1 :
					start();
					break;
				case 2 :
					stop();
					break;
				case 3 :
					listClients();
					break;
				case 4 :
					sendMessage();
					break;
				case 5 :
					messageList();
					break;
				case 6 :
					reloadUsers();
					break;
				case 7 :
					logToScreen();
					break;
				case 0 :
					exit();
					break;
				case -1 :
					// default option if entering an option went wrong
					break;
				default :
					System.out.println("Invalid option. Choose between 0 and 6.");
					break;
			}
		}

		System.out.println("Exiting simulator.");
		debug.write("simulator exited.");
	}

	/**
	 * Permits a user to choose the port where to listen on and then creates and
	 * starts new instance of <code>SMSCListener</code>.
	 * An instance of the <code>SimulatorPDUProcessor</code> is created 
	 * and this instance is passed to the <code>SMSCListener</code> which is started
	 * just after.
	 */
	protected void start() throws IOException {
		if (smscListener == null) {
			System.out.print("Enter port number> ");
			int port = Integer.parseInt(keyboard.readLine());
			System.out.print("Starting listener... ");
			smscListener = new SMSCListenerImpl(port, true);
			processors = new PDUProcessorGroup();
			messageStore = new ShortMessageStore();
			deliveryInfoSender = new DeliveryInfoSender();
			deliveryInfoSender.start();
			users = new Table(usersFileName);
			factory = new SimulatorPDUProcessorFactory(processors, messageStore, deliveryInfoSender, users);
			factory.setDisplayInfo(displayInfo);
			smscListener.setPDUProcessorFactory(factory);
			smscListener.start();
			System.out.println("started.");
		} else {
			System.out.println("Listener is already running.");
		}
	}

	/**
	 * Stops all the currently active sessions and then stops the listener.
	 */
	protected void stop() throws IOException {
		if (smscListener != null) {
			System.out.println("Stopping listener...");
			synchronized (processors) {
				int procCount = processors.count();
				SimulatorPDUProcessor proc;
				SMSCSession session;
				for (int i = 0; i < procCount; i++) {
					proc = (SimulatorPDUProcessor) processors.get(i);
					session = proc.getSession();
					System.out.print("Stopping session " + i + ": " + proc.getSystemId() + " ...");
					session.stop();
					System.out.println(" stopped.");
				}
			}
			smscListener.stop();
			smscListener = null;
			if (deliveryInfoSender != null) {
				deliveryInfoSender.stop();
			}
			System.out.println("Stopped.");
		}
	}

	/**
	 * Stops all the currently active sessions, stops the listener
	 * and the exits the application.
	 */
	protected void exit() throws IOException {
		stop();
		keepRunning = false;
	}

	/**
	 * Prints all messages currently present in the message store
	 * on the standard output.
	 */
	protected void messageList() {
		if (smscListener != null) {
			messageStore.print();
		} else {
			System.out.println("You must start listener first.");
		}
	}

	/**
	 * Reloads the user (client) definition file used for authentication of
	 * bounding ESMEs. Useful when the user setting is changed or added
	 * and restart of the simulator is not possible.
	 */
	protected void reloadUsers() {
		if (smscListener != null) {
			try {
				if (users != null) {
					users.reload();
				} else {
					users = new Table(usersFileName);
				}
				System.out.println("Users file reloaded.");
			} catch (FileNotFoundException e) {
				event.write(e, "reading users file " + usersFileName);
			} catch (IOException e) {
				event.write(e, "reading users file " + usersFileName);
			}
		} else {
			System.out.println("You must start listener first.");
		}
	}

	/**
	 * Changes the log to screen status. If logging to screen,
	 * an information about received and sent PDUs as well as about
	 * connection attempts is printed to standard output.
	 */
	protected void logToScreen() {
		if (smscListener != null) {
			synchronized (processors) {
				displayInfo = !displayInfo;
				int procCount = processors.count();
				SimulatorPDUProcessor proc;
				for (int i = 0; i < procCount; i++) {
					proc = (SimulatorPDUProcessor) processors.get(i);
					proc.setDisplayInfo(displayInfo);
				}
			}
			factory.setDisplayInfo(displayInfo);
		}
	}

	/**
	 * Prints all currently connected clients on the standard output.
	 */
	protected void listClients() {
		if (smscListener != null) {
			synchronized (processors) {
				int procCount = processors.count();
				if (procCount > 0) {
					SimulatorPDUProcessor proc;
					for (int i = 0; i < procCount; i++) {
						proc = (SimulatorPDUProcessor) processors.get(i);
						System.out.print(proc.getSystemId());
						if (!proc.isActive()) {
							System.out.println(" (inactive)");
						} else {
							System.out.println();
						}
					}
				} else {
					System.out.println("No client connected.");
				}
			}
		} else {
			System.out.println("You must start listener first.");
		}
	}

	/**
	 * Permits data to be sent to a specific client.
	 * With the id of the client set by the user, the method <code>sendMessage</code> 
	 * gets back the specific reference to the client's <code>PDUProcessor</code>.
	 * With this reference you are able to send data to the client.
	 */
	protected void sendMessage() throws IOException {
		if (smscListener != null) {
			int procCount = processors.count();
			if (procCount > 0) {
				String client;
				SimulatorPDUProcessor proc;
				listClients();
				if (procCount > 1) {
					System.out.print("Type name of the destination> ");
					client = keyboard.readLine();
				} else {
					proc = (SimulatorPDUProcessor) processors.get(0);
					client = proc.getSystemId();
				}
				for (int i = 0; i < procCount; i++) {
					proc = (SimulatorPDUProcessor) processors.get(i);
					if (proc.getSystemId().equals(client)) {
						if (proc.isActive()) {
							System.out.print("Type the message> ");
							String message = keyboard.readLine();
							DeliverSM request = new DeliverSM();
							try {
								request.setShortMessage(message);
								proc.serverRequest(request);
								System.out.println("Message sent.");
							} catch (WrongLengthOfStringException e) {
								System.out.println("Message sending failed");
								event.write(e, "");
							} catch (IOException ioe) {
							} catch (PDUException pe) {
							}
						} else {
							System.out.println("This session is inactive.");
						}
					}
				}
			} else {
				System.out.println("No client connected.");
			}
		} else {
			System.out.println("You must start listener first.");
		}
	}
}
/*
 * $Log: Simulator.java,v $
 * Revision 1.3  2006/03/09 16:24:15  sverkera
 * Removed compiler and javadoc warnings
 *
 * Revision 1.2  2003/09/30 09:17:49  sverkera
 * Created an interface for SMSCListener and SMSCSession and implementations of them  so that it is possible to provide other implementations of these classes.
 *
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 * 
 * Old changelog:
 * 20-09-01 ticp@logica.com added support for sending of delivery info
 * 26-09-01 ticp@logica.com debug now in a group
 */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
最新欧美精品一区二区三区| 成人久久18免费网站麻豆| 日韩欧美另类在线| 成人爽a毛片一区二区免费| 首页亚洲欧美制服丝腿| 国产精品久久久爽爽爽麻豆色哟哟| 91精品国产综合久久小美女| 97se亚洲国产综合自在线观| 韩国一区二区在线观看| 亚洲综合色噜噜狠狠| 国产三级精品视频| 日韩亚洲欧美在线观看| 在线观看国产精品网站| wwwwxxxxx欧美| 欧美喷潮久久久xxxxx| 91视频一区二区| 国产成+人+日韩+欧美+亚洲| 蜜臀精品一区二区三区在线观看 | 日韩av一区二区三区四区| 国产精品第13页| 久久久久久亚洲综合| 欧美色网站导航| 色综合天天综合色综合av| 欧美一区二区三区日韩视频| 欧美性感一区二区三区| 91原创在线视频| 本田岬高潮一区二区三区| 国产在线精品免费av| 日本亚洲视频在线| 日本欧美一区二区三区| 日韩高清一区在线| 亚洲v精品v日韩v欧美v专区| 玉足女爽爽91| 最新中文字幕一区二区三区| 国产精品久久久久7777按摩| 久99久精品视频免费观看| 午夜成人免费电影| 天天色天天操综合| 亚洲国产日日夜夜| 午夜影院久久久| 亚洲午夜视频在线| 亚洲国产成人tv| 亚洲国产aⅴ成人精品无吗| 亚洲综合视频在线| 香蕉影视欧美成人| 五月天婷婷综合| 秋霞国产午夜精品免费视频| 男人的j进女人的j一区| 欧美日韩国产片| 欧美另类z0zxhd电影| 欧美精品乱人伦久久久久久| 51精品国自产在线| 日韩亚洲欧美综合| 久久久久久久久久久黄色| 久久精品一区二区三区四区| 国产日本亚洲高清| 中文字幕在线一区免费| 一区二区三区四区视频精品免费 | 欧美亚日韩国产aⅴ精品中极品| av在线综合网| 欧美日韩视频第一区| 精品日韩99亚洲| 欧美国产欧美综合| 亚洲精品视频观看| 日韩综合一区二区| 国产精品综合二区| 91免费在线看| 日韩欧美一卡二卡| 欧美激情一区二区三区全黄| 一区二区三区在线免费观看| 免费成人在线播放| 成人黄色网址在线观看| 国产精品久久毛片| 日韩成人伦理电影在线观看| 国产成人在线视频网站| 91国产精品成人| 欧美tk—视频vk| 1区2区3区精品视频| 调教+趴+乳夹+国产+精品| 国产精品一区久久久久| 在线观看免费视频综合| 精品美女在线观看| 亚洲色图另类专区| 麻豆中文一区二区| 99久久99久久精品免费看蜜桃| 欧美精品乱人伦久久久久久| 日本不卡视频在线观看| 成人av电影免费在线播放| 7777精品伊人久久久大香线蕉的| 久久精品夜色噜噜亚洲a∨| 亚洲一区在线播放| 国产剧情一区二区| 欧美日韩成人在线| 国产精品久久久久国产精品日日| 日韩国产欧美在线观看| 91色porny在线视频| 日韩欧美另类在线| 亚洲一区二区在线免费看| 国产精品1区2区3区| 欧美日韩高清不卡| 国产黄色成人av| 91精品免费在线观看| 一区二区三区精品久久久| 国产精品一区二区免费不卡 | 91福利视频在线| 欧美精品一区二区三区在线 | 国产成人av电影在线| 欧美日韩国产大片| 亚洲激情成人在线| 成人免费三级在线| 精品蜜桃在线看| 青青草国产精品亚洲专区无| 国产精品美女一区二区| 国产精品资源在线| 精品免费国产二区三区| 青青草原综合久久大伊人精品优势| 91福利资源站| 亚洲美女一区二区三区| 成人免费黄色大片| 国产日韩亚洲欧美综合| 韩国v欧美v日本v亚洲v| 日韩亚洲欧美成人一区| 亚洲成va人在线观看| 色综合久久综合网| 亚洲欧美一区二区久久| 99在线精品观看| 国产精品系列在线| 精品国内二区三区| 美女视频黄a大片欧美| 欧美精品久久久久久久多人混战| 一区二区三区四区亚洲| 在线观看一区二区精品视频| 又紧又大又爽精品一区二区| 色综合久久综合网欧美综合网| 中文字幕一区二区日韩精品绯色| 成人综合在线观看| 国产精品传媒在线| 一本大道av一区二区在线播放| ...av二区三区久久精品| 日韩av在线播放中文字幕| 欧美一卡二卡在线| 美女一区二区三区| 日韩精品五月天| 欧美一区三区二区| 六月婷婷色综合| 2019国产精品| 国产福利一区二区| 国产精品网曝门| 99精品1区2区| 亚洲第一狼人社区| 欧美一级生活片| 国产一区亚洲一区| 国产精品女同互慰在线看| 91玉足脚交白嫩脚丫在线播放| 亚洲精品美国一| 欧美乱妇23p| 国产一区二区三区日韩| 中文成人av在线| 国产精品第四页| 欧美主播一区二区三区美女| 日本系列欧美系列| 国产亚洲精品bt天堂精选| 成人激情午夜影院| 亚洲黄色录像片| 日韩欧美国产一区在线观看| 国产精品亚洲一区二区三区在线| 国产精品国产三级国产普通话蜜臀 | 欧美精品日韩一本| 国内精品伊人久久久久av影院| 国产精品免费丝袜| 欧美体内she精高潮| 3d动漫精品啪啪1区2区免费 | 一个色综合网站| 91精品国产色综合久久ai换脸 | 国产欧美日韩另类一区| 91在线观看成人| 免费观看一级欧美片| 国产精品网站导航| 欧美美女bb生活片| 国产馆精品极品| 亚洲一区在线视频| 欧美国产精品v| 亚洲美女偷拍久久| 精品国产凹凸成av人导航| 91丝袜美女网| 久久er精品视频| 尤物av一区二区| 国产午夜精品一区二区三区四区| 欧美综合亚洲图片综合区| 国产一区二区三区久久久| 亚洲国产精品久久人人爱蜜臀| 久久日韩粉嫩一区二区三区| 欧美日韩久久久久久| 粗大黑人巨茎大战欧美成人| 日韩av一级片| 一区二区三区精品| 日韩理论片网站| 国产日韩欧美精品综合| 日韩三级av在线播放| 欧美午夜电影在线播放|