📄 smgpreceivethread.java~1~
字号:
package com.pansonlu.smgp;/** * <p>Title: SMGP Interface</p> * <p>Description: 湖南移动短信网关通讯程序</p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: sunun tech ltd.</p> * @author pansonlu * @version 1.0 */import java.io.*;import java.net.*;import com.pansonlu.common.util.*;public class SMGPReceiveThread extends Thread{ /** 该线程运行标志 true 在运行,false停止 **/ public static boolean isAvail = false; private static DataInputStream inputStream; private static DataOutputStream outputStream; /** 初始化构造器 * 使用SMGPSocketProcess唯一的实例的输入流和输出流**/ public SMGPReceiveThread() { inputStream = SMGPSocketProcess.getInstance().inputStream; outputStream = SMGPSocketProcess.getInstance().outputStream; isAvail = true; } public void run(){ Debug.outInfo("[SMGPMaster]"+PublicFunction.getFormatTime()+" MO线程("+SMGParameter.ServerPort+")->接收线程启动 ..."); while(SMGPSocketProcess.getInstance().isAvail && isAvail){ try{ byte[] recByte = PublicFunction.recv(inputStream); SMGP deliverMsg = new SMGP(); deliverMsg.parsePack(recByte); switch(deliverMsg.RequestID){ case SMGP.SMGP_DELIVER: //将Deliver消息保存在接收缓冲中,由SMGPSocketProcess的SMGPMODataSaveThread //线程将MO数据保存在数据库中 synchronized(SMGPDBAccess.getInstance().vctMOData){ SMGPDBAccess.getInstance().vctMOData.addElement(deliverMsg); } //回应Deliver消息 SMGP deliverRespMsg = new SMGP(SMGP.SMGP_DELIVER_RESP); deliverRespMsg.MsgID = deliverMsg.MsgID; deliverRespMsg.SequenceID = deliverMsg.SequenceID; deliverRespMsg.Status = 0; PublicFunction.send(outputStream, deliverRespMsg.pack()); break; case SMGP.SMGP_ACTIVE_TEST_RESP: //链路测试响应,无处理 //System.out.println("SMGP.SMGP_ACTIVE_TEST_RESP"); break; case SMGP.SMGP_SUBMIT_RESP: if(deliverMsg.Status ==0){ //SMGPDBAccess.getInstance().saveRespRelate(deliverMsg); Debug.outInfo("[SMGPMaster]发送短信成功,SequenceID:" +deliverMsg.SequenceID+" Relat MsgID: "+deliverMsg.BCDMsgID); } else{ Debug.outInfo("[SMGPMaster]发送短信失败,错误状态码:" +deliverMsg.Status+" MsgID:" +deliverMsg.SequenceID+"") ; } //处理成功下发的响应信息 //SMGPDBAccess.getInstance().dealProccessMsg(deliverMsg); synchronized(SMGPDBAccess.getInstance().vctRespMsg){ SMGPDBAccess.getInstance().vctRespMsg.addElement(deliverMsg); } break; } } catch(Exception ex){ destory(ex); } } // end while } /** 销毁线程 **/ public void destory(Exception ex){ if(ex !=null){ ex.printStackTrace(); Debug.outInfo("[SMGP]MO连接(收)线程异常停止,异常原因:" + ex.getMessage()); } else{ Debug.outInfo("[SMGP]MO连接(收)线程异常停止"); } SMGPSocketProcess.getInstance().disclose(); this.isAvail = false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -