cmppeventadapter.java

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

JAVA
60
字号
package com.huawei.smproxy;

import com.huawei.insa2.comm.PEventAdapter;
import com.huawei.insa2.comm.PException;
import com.huawei.insa2.comm.PLayer;
import com.huawei.insa2.comm.cmpp.CMPPConnection;
import com.huawei.insa2.comm.cmpp.CMPPConstant;
import com.huawei.insa2.comm.cmpp.CMPPTransaction;
import com.huawei.insa2.comm.cmpp.message.CMPPActiveRepMessage;
import com.huawei.insa2.comm.cmpp.message.CMPPDeliverMessage;
import com.huawei.insa2.comm.cmpp.message.CMPPMessage;
import com.huawei.insa2.comm.cmpp.message.CMPPTerminateRepMessage;

public class CMPPEventAdapter extends PEventAdapter {

	private SMProxy smProxy;

	private CMPPConnection conn;

	public CMPPEventAdapter(SMProxy smProxy) {
		this.smProxy = null;
		conn = null;
		this.smProxy = smProxy;
		conn = smProxy.getConn();
	}

	public void childCreated(PLayer child) {
		CMPPTransaction t = (CMPPTransaction) child;
		CMPPMessage msg = t.getResponse();
		CMPPMessage resmsg = null;

		if (msg.getCommandId() == CMPPConstant.Terminate_Command_Id) {
			resmsg = new CMPPTerminateRepMessage();
			smProxy.onTerminate();
		} else if (msg.getCommandId() == CMPPConstant.Active_Test_Command_Id)
			resmsg = new CMPPActiveRepMessage(0);
		else if (msg.getCommandId() == CMPPConstant.Deliver_Command_Id) {
			CMPPDeliverMessage tmpmes = (CMPPDeliverMessage) msg;
			resmsg = smProxy.onDeliver(tmpmes);
		} else {
			t.close();
		}

		if (resmsg != null) {
			try {
				t.send(resmsg);
			} catch (PException e) {
				e.printStackTrace();
			}
			t.close();
		}
		
		if (msg.getCommandId() == CMPPConstant.Terminate_Command_Id) {
			conn.close();
		}

	}

}

⌨️ 快捷键说明

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