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

📄 cmppclientresponse.java

📁 短信网关发送接受平台。
💻 JAVA
字号:
import java.lang.*;
import java.net.*;
import java.io.*;

import CMPPResponse;

import CMPPTerminate;
import CMPPTerminateResponse;

import CMPPDeliver;
import CMPPDeliverResponse;


public class CMPPClientResponse extends CMPPResponse
{
	CMPPPacket m_packet = null;

	public CMPPClientResponse(CMPPSynchronizedIO synio,CMPPAsynchronizedIO asynio,CMPPPacket packet)
		throws CMPPException
	{
		super(synio,asynio);
		m_packet = packet;
	}

	protected void OnTerminateResponse(CMPPTerminateResponse response,CMPPTerminate terminate)
	{
		m_asynio.m_bTerminate = true;
	}

	protected void OnDeliverResponse(CMPPDeliverResponse response,CMPPDeliver deliver)
	{
		response.msg_id = deliver.msg_id;
		response.result = 0;//正确
	}

	public void run()
	{
		m_nStatus = THREAD_RUNNING;

		try
		{
			if(isRunning() && m_packet != null)
			{
				if(m_packet.command_id == CMPPCommandID.CMPP_TERMINATE)
				//CMPP_TERMINATE
				{
					CMPPTerminate terminate = new CMPPTerminate(m_packet);
					
					CMPPTerminateResponse response = response(terminate);
					if(response != null)
					{
						//同步输出响应
						//通讯马上就要关闭,必须同步输出!
						m_synio.write(response);
					}
					else
					{
						CMPPLog.log("CMPPClientResponse.run : failure on terminate response !",
							CMPPLog.LOG_CMPP_CLIENT_RESPONSE);
					}
				}
				else if(m_asynio.m_bAuthenticated)
				//已经效验有效
				{
					if(m_packet.command_id == CMPPCommandID.CMPP_ACTIVETEST)
					//CMPP_ACTIVETEST
					{
						CMPPActiveTest activetest = new CMPPActiveTest(m_packet);
						
						CMPPActiveTestResponse response = response(activetest);
						if(response == null || !m_asynio.write(response))
						{
							m_asynio.m_nErrorCount ++;
							
							CMPPLog.log("CMPPClientResponse.run : failure on activetest response !",
								CMPPLog.LOG_CMPP_CLIENT_RESPONSE);
						}
					}
					else if(m_packet.command_id == CMPPCommandID.CMPP_DELIVER)
					//CMPP_DELIVER
					{
						CMPPDeliver deliver = new CMPPDeliver(m_packet);
						
						CMPPDeliverResponse response = response(deliver);
						if(response == null || !m_asynio.write(response))
						{
							m_asynio.m_nErrorCount ++;
							
							CMPPLog.log("CMPPClientResponse.run : failure on deliver response !",
								CMPPLog.LOG_CMPP_CLIENT_RESPONSE);
						}
					}
					else
					{
						CMPPLog.log("CMPPClientResponse.run : unhandled request !",
							CMPPLog.LOG_CMPP_CLIENT_RESPONSE);
					}
				}
				else
				{
					CMPPLog.log("CMPPClientResponse.run : unauthorized request !",
						CMPPLog.LOG_CMPP_CLIENT_RESPONSE);
				}
			}
		}
		catch(Exception e)
		{
			CMPPLog.log(e.getMessage(),
				CMPPLog.LOG_CMPP_CLIENT_RESPONSE | LogRequest.LOG_EXCEPTION);
			CMPPLog.log("CMPPClientResponse.run : unexpected exit !",
				CMPPLog.LOG_CMPP_CLIENT_RESPONSE | LogRequest.LOG_EXCEPTION);
		}
	
		m_nStatus = THREAD_STOPPED;
	}	
}

⌨️ 快捷键说明

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