smppsmproxy.java

来自「华为CNGP.CMPP.SGIP.CMPP源代码。」· Java 代码 · 共 64 行

JAVA
64
字号
package com.huawei.smproxy;

import java.io.IOException;
import java.util.Map;

import com.huawei.insa2.comm.smpp.SMPPConnection;
import com.huawei.insa2.comm.smpp.SMPPTransaction;
import com.huawei.insa2.comm.smpp.message.SMPPDeliverMessage;
import com.huawei.insa2.comm.smpp.message.SMPPDeliverRespMessage;
import com.huawei.insa2.comm.smpp.message.SMPPMessage;
import com.huawei.insa2.util.Args;

public class SMPPSMProxy {

	public SMPPSMProxy(Map args) {
		this(new Args(args));
	}

	public SMPPSMProxy(Args args) {
		conn = new SMPPConnection(args);
		conn.addEventListener(new SMPPEventAdapter(this));
		conn.waitAvailable();
		if (!conn.available()) {
			throw new IllegalStateException(conn.getError());
		}
	}

	public SMPPMessage send(SMPPMessage message) throws IOException {
		if (message == null)
			return null;
		SMPPTransaction t = (SMPPTransaction) conn.createChild();
		try {
			t.send(message);
			t.waitResponse();
			SMPPMessage rsp = t.getResponse();
			SMPPMessage smppmessage = rsp;
			return smppmessage;
		} finally {
			t.close();
		}
	}

	public void onTerminate() {
	}

	public SMPPMessage onDeliver(SMPPDeliverMessage msg) {
		return new SMPPDeliverRespMessage(0);
	}

	public void close() {
		conn.close();
	}

	public SMPPConnection getConn() {
		return conn;
	}

	public String getConnState() {
		return conn.getError();
	}

	private SMPPConnection conn;
}

⌨️ 快捷键说明

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