?? cmppmoreceivethread.java
字號(hào):
package com.pansonlu.cmpp;/** * <p>Title: CMPP Interface</p> * <p>Description: 湖南移動(dòng)短信網(wǎng)關(guān)通訊程序</p> * <p>Copyright: Copyright (c) 2008</p> * <p>Company: Sunrise tech ltd.</p> * @author pansonlu * @version 1.0 */import java.io.*;import java.net.*;import com.pansonlu.common.util.*;public class CMPPMOReceiveThread extends Thread{ /** 該線程運(yùn)行標(biāo)志 true 在運(yùn)行,false停止 **/ public static boolean isAvail = false; private static DataInputStream inputStream; private static DataOutputStream outputStream; /** 初始化構(gòu)造器 * 使用CMPPMOSocketProcess唯一的實(shí)例的輸入流和輸出流**/ public CMPPMOReceiveThread() { inputStream = CMPPMOSocketProcess.getInstance().inputStream; outputStream = CMPPMOSocketProcess.getInstance().outputStream; isAvail = true; } public void run(){ Debug.outInfo("[CMPPMaster]"+PublicFunction.getFormatTime()+" MO連接("+CMPParameter.MOServerPort+")->接收線程啟動(dòng) ..."); while(CMPPMOSocketProcess.getInstance().isAvail && isAvail){ try{ byte[] recByte = PublicFunction.recv(inputStream); CMPP deliverMsg = new CMPP(); deliverMsg.parsePack(recByte); switch(deliverMsg.Command_Id){ case CMPP.CMPP_DELIVER: //將Deliver消息保存在接收緩沖中,由CMPPMOSocketProcess的CMPPMODataSaveThread //線程將MO數(shù)據(jù)保存在數(shù)據(jù)庫(kù)中 CMPPDBAccess.getInstance().vctMOData.addElement(deliverMsg); //回應(yīng)Deliver消息 CMPP deliverRespMsg = new CMPP(CMPP.CMPP_DELIVER_RESP); deliverRespMsg.Msg_Id = deliverMsg.Msg_Id; deliverRespMsg.Result = 0; PublicFunction.send(outputStream, deliverRespMsg.pack()); break; case CMPP.CMPP_ACTIVE_TEST_RESP: //鏈路測(cè)試響應(yīng),無處理 break; case CMPP.CMPP_SUBMIT_RESP: //處理成功下發(fā)的響應(yīng)信息 CMPPDBAccess.getInstance().dealProccessMsg(deliverMsg); break; } } catch(Exception ex){ destory(ex); } } // end while } /** 銷毀線程 **/ public void destory(Exception ex){ if(ex !=null){ ex.printStackTrace(); Debug.outInfo("[CMPP]MO連接(收)線程異常停止,異常原因:" + ex.getMessage()); } else{ Debug.outInfo("[CMPP]MO連接(收)線程異常停止"); } CMPPMOSocketProcess.getInstance().disclose(); this.isAvail = false; }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -