⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notestart.java

📁 java 编写的短信平台。支持所有协议
💻 JAVA
字号:
package com.sf.note;


import com.huawei.insa2.util.Args;
import com.huawei.insa2.util.Cfg;

public class NoteStart {
	
	private boolean isStart = false;
	
	private static NoteStart noteStart = null;
	
	private static Cmpp20Proxy smp20 = null;
	
	private static Cmpp30Proxy smp30 = null;
	
	public static synchronized NoteStart getInstance() {
		if (noteStart == null) {
			noteStart = new NoteStart();
		}
		return noteStart;
	}
	
	public void start(int version) {
		if (version != 2 && version != 3) {
			return;
		}
		if (!isStart) {
			try {
				Constant.ISMG_VERSION = version;
				SendNoteHandleThread st = new SendNoteHandleThread();
				Args args = null;
				
				if (Constant.ISMG_VERSION == 2) {
				   args = new Cfg("conf/SMProxy20.xml").getArgs("ismg");
				   smp20 = new Cmpp20Proxy(args);
				   st.setCmpp20Proxy(smp20);
				}
				if (Constant.ISMG_VERSION == 3) {
					args = new Cfg("conf/SMProxy30.xml").getArgs("ismg");
					smp30 = new Cmpp30Proxy(args);
					st.setCmpp30Proxy(smp30);
				}
				new Thread(new MoniterThread()).start();
				new Thread(st).start();
			} catch (Exception e) {
				e.printStackTrace();
			}
			isStart = true;
		}
	}
	
	public static void main(String[] args) {
		NoteStart.getInstance().start(2);
		
		try {
	
			new NoteSender().sendNote("8613952065156","8613906631212","ssss");
			Thread.sleep(10000);
			new NoteSender().sendNote("8613952065156","8613906631212","1");
		} catch (Exception e) {

			e.printStackTrace();
		}
	}
	

	private class MoniterThread implements Runnable {

		public void run() {
			String connState = null;
			try {
				do {
					if (Constant.ISMG_VERSION == 2) {
					   connState = smp20.getConnState();
					}
					if (Constant.ISMG_VERSION == 3) {
						connState = smp30.getConnState();
					}
					if (connState == null) {
						//connState = "系统运行正常";
					}
					Thread.sleep(10000);
				} while (true);
			} catch (Exception e) {
				System.out.println("状态监控线程出现异常退出");
				e.printStackTrace();
				return;
			}
		}

		public MoniterThread() {
			//setDaemon(true);
		}

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -